Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Warning: reset() expects parameter 1 to be array, boolean given in


qspider

Recommended Posts

Hi all!

 

I just installed the address management add on. Then I installed a tax exempt add on. While in the administration, customers and editing a customers account by clicking on an address i receive these errors.

 

Warning: reset() expects parameter 1 to be array, boolean given in /public_html/admin/includes/classes/object_info.php on line 17

 

Warning: Variable passed to each() is not an array or object in /home/timerco/public_html/admin/includes/classes/object_info.php on line 18

 

I look in objects_info.php and I don't see anything wrong but i see it is calling an array.

 

<?php
/*
 $Id$

 osCommerce, Open Source E-Commerce Solutions
 http://www.oscommerce.com

 Copyright (c) 2003 osCommerce

 Released under the GNU General Public License
*/

 class objectInfo {

// class constructor
   function objectInfo($object_array) {
     reset($object_array);
     while (list($key, $value) = each($object_array)) {
       $this->$key = tep_db_prepare_input($value);
     }
   }
 }
?>

I then go to look in /admin/customers.php because that's the page where the error happens but I'm not really sure what I'm looking for. I decided to look for object and I found some object arrays and (cinfo). Not really sure what to do. It appears that an array is supposed to be sent but instead it is sending a boolean value.

 

<?php
/*
 $Id$

 osCommerce, Open Source E-Commerce Solutions
 http://www.oscommerce.com

 Copyright (c) 2010 osCommerce

 Released under the GNU General Public License
*/

 require('includes/application_top.php');

 function format_US_Canada_phone($phone) {
   $temp = '';
   for ($x = 0; $x < strlen($phone); $x++) { // strip non-digits
     $c = substr($phone, $x, 1);
     if (($c >= '0') && ($c <= '9')) $temp .= $c;
   }
   if (substr($temp, 0, 1) == '1') $temp = substr($temp, 1); // strip leading 1, long distance indicator
   if (strlen($temp) == 7)  // phone number without area code
     return substr($temp, 0, 3) . '-' . substr($temp, 3);
   if (strlen($temp) < 10) return false; // phone number too short
   if (strlen($temp) > 10) { // phone number includes extension
     return '(' . substr($temp, 0, 3) . ') ' . substr($temp, 3, 3) . '-' . substr($temp, 6, 4) . ' ext. ' . substr($temp, 10);
   } else { // standard phone number with area code
     return '(' . substr($temp, 0, 3) . ') ' . substr($temp, 3, 3) . '-' . substr($temp, 6, 4);
   }
 }

 function address_label($customers_id, $address_id = 1) {
   if (is_array($address_id) && !empty($address_id)) {
     return tep_address_format($address_id['address_format_id'], $address_id, true, '', '<br />');
   }

   $address_query = tep_db_query("select entry_firstname as firstname, entry_lastname as lastname, entry_company as company, entry_street_address as street_address, entry_address2 as address2, entry_suburb as suburb, entry_city as city, entry_postcode as postcode, entry_state as state, entry_zone_id as zone_id, entry_country_id as country_id from " . TABLE_ADDRESS_BOOK . " where customers_id = '" . (int)$customers_id . "' and address_book_id = '" . (int)$address_id . "'");
   $address = tep_db_fetch_array($address_query);
   $address_format_query = tep_db_query("select address_format_id from " . TABLE_COUNTRIES . " where countries_id = '" . (int)$address['country_id'] . "'");
   if (tep_db_num_rows($address_format_query) == 1) {
     $address_format = tep_db_fetch_array($address_format_query);
     $format_id = $address_format['address_format_id'];
   } else {
     $format_id = '1';
   }

   return tep_address_format($format_id, $address, true, '', '<br />');
 }

 $action = (isset($HTTP_GET_VARS['action']) ? $HTTP_GET_VARS['action'] : '');

 $error = false;
 $processed = false;
 $customers_id = tep_db_prepare_input($HTTP_GET_VARS['cID']);
 $check = tep_db_query("select customers_default_address_id, customers_default_billing_address_id, customers_default_shipping_address_id from " . TABLE_CUSTOMERS . " where customers_id = " . (int)$customers_id);
 $default_addresses = tep_db_fetch_array($check);
 $address_id = (isset($HTTP_GET_VARS['aid']) ? $HTTP_GET_VARS['aid'] : $default_addresses['customers_default_address_id']);

 if (tep_not_null($action)) {
   switch ($action) {
     case 'savepwd':
       require('includes/functions/password_funcs.php');
       $newpwd = tep_db_prepare_input($HTTP_POST_VARS['pwd']);
       tep_db_query("update " . TABLE_CUSTOMERS . " set customers_password = '" . tep_encrypt_password($newpwd) . "' where customers_id = '" . (int)$customers_id . "'");
       $check_customer_query = tep_db_query("select customers_firstname, customers_lastname, customers_password, customers_email_address from " . TABLE_CUSTOMERS . " where customers_id = '" . (int)$customers_id . "'");
       $check_customer = tep_db_fetch_array($check_customer_query);
       if (tep_validate_password($newpwd, $check_customer['customers_password'])) {
         tep_mail($check_customer['customers_firstname'] . ' ' . $check_customer['customers_lastname'], $check_customer['customers_email_address'], EMAIL_PASSWORD_REMINDER_SUBJECT, sprintf(EMAIL_PASSWORD_REMINDER_BODY, $newpwd, strlen($newpwd)), STORE_OWNER, STORE_OWNER_EMAIL_ADDRESS);
         $messageStack->add_session(SUCCESS_PASSWORD_SENT, 'success');
       } else {
         $messageStack->add_session(ERROR_PWD, 'error');
       }
       tep_redirect(tep_href_link(FILENAME_CUSTOMERS, tep_get_all_get_params(array('action'))));
       break;
     case 'setdefault':
       $type = $HTTP_GET_VARS['type'];
       $check_query = tep_db_query("select count(*) as total from " . TABLE_CUSTOMERS . " where customers_id = " . (int)$customers_id);
       $check = tep_db_fetch_array($check_query);
       if ($check['total'] != 1) tep_redirect(tep_href_link(FILENAME_CUSTOMERS)); // no such customer
       $check_query = tep_db_query("select count(*) as total from " . TABLE_ADDRESS_BOOK . " where customers_id = '" . (int)$customers_id . "' and address_book_id = '" . (int)$address_id . "'");
       $check = tep_db_fetch_array($check_query);
       if ($check['total'] != 1) // no such address for customer
         tep_redirect(tep_href_link(FILENAME_CUSTOMERS), tep_get_all_get_params(array('action', 'aid')));
       if ($type == 'M') {
         tep_db_query(" update " . TABLE_CUSTOMERS . " set customers_default_address_id = " . (int)$address_id . " where customers_id = " . (int)$customers_id);
       } elseif ($type == 'B') {
         tep_db_query(" update " . TABLE_CUSTOMERS . " set customers_default_billing_address_id = " . (int)$address_id . " where customers_id = " . (int)$customers_id);
       } elseif ($type == 'S') {
         tep_db_query(" update " . TABLE_CUSTOMERS . " set customers_default_shipping_address_id = " . (int)$address_id . " where customers_id = " . (int)$customers_id);
       }
       tep_redirect(tep_href_link(FILENAME_CUSTOMERS, tep_get_all_get_params(array('action', 'type')) . 'action=edit'));
       break;
     case 'confirmaddressdelete':
       if (!isset($HTTP_GET_VARS['cID']) || !isset($HTTP_GET_VARS['aid'])) // if either id not set
         tep_redirect(tep_href_link(FILENAME_CUSTOMERS, tep_get_all_get_params(array('action'))));
       $check_default_query = tep_db_query("select customers_default_address_id, customers_default_billing_address_id, customers_default_shipping_address_id from " . TABLE_CUSTOMERS . " where customers_id = '" . (int)$customers_id . "'");
       if ($defaults = tep_db_fetch_array($check_default_query)) {
         if (in_array($address_id, $defaults)) { // may not delete a default address
           tep_redirect(tep_href_link(FILENAME_CUSTOMERS, tep_get_all_get_params(array('action')) . 'action=edit'));
         } else {
           tep_db_query("delete from " . TABLE_ADDRESS_BOOK . " where customers_id = '" . (int)$customers_id . "' and address_book_id = '" . (int)$address_id . "'");
           tep_redirect(tep_href_link(FILENAME_CUSTOMERS, tep_get_all_get_params(array('action', 'aid')) . 'action=edit'));
         }
       } else { // no match on cID
         tep_redirect(tep_href_link(FILENAME_CUSTOMERS, tep_get_all_get_params(array('cID', 'action', 'aid'))));
       }
       break;
     case 'update':
       $customers_firstname = tep_db_prepare_input($HTTP_POST_VARS['customers_firstname']);
       $customers_lastname = tep_db_prepare_input($HTTP_POST_VARS['customers_lastname']);
       $entry_firstname = tep_db_prepare_input($HTTP_POST_VARS['entry_firstname']);
       $entry_lastname = tep_db_prepare_input($HTTP_POST_VARS['entry_lastname']);
       $customers_email_address = tep_db_prepare_input($HTTP_POST_VARS['customers_email_address']);
       $customers_telephone = tep_db_prepare_input($HTTP_POST_VARS['customers_telephone']);
       $customers_alternate_telephone = tep_db_prepare_input($HTTP_POST_VARS['customers_alternate_telephone']);
       $customers_fax = tep_db_prepare_input($HTTP_POST_VARS['customers_fax']);
       $customers_newsletter = tep_db_prepare_input($HTTP_POST_VARS['customers_newsletter']);
       // FWR TAX EXEMPT
 $customers_tax_exempt = tep_db_prepare_input($HTTP_POST_VARS['tax_exempt']);
 $customers_tax_exempt_id = tep_db_prepare_input($HTTP_POST_VARS['tax_exempt_id']);
 $customers_org_type = tep_db_prepare_input($HTTP_POST_VARS['org_type']);
 // END FWR TAX EXEMPT

       $customers_gender = tep_db_prepare_input($HTTP_POST_VARS['customers_gender']);
       $customers_dob = tep_db_prepare_input($HTTP_POST_VARS['customers_dob']);

       $entry_street_address = tep_db_prepare_input($HTTP_POST_VARS['entry_street_address']);
       $entry_address2 = tep_db_prepare_input($HTTP_POST_VARS['entry_address2']);
       $entry_suburb = tep_db_prepare_input($HTTP_POST_VARS['entry_suburb']);
       $entry_postcode = strtoupper(tep_db_prepare_input($HTTP_POST_VARS['entry_postcode']));
       $entry_city = tep_db_prepare_input($HTTP_POST_VARS['entry_city']);
       $entry_country_id = tep_db_prepare_input($HTTP_POST_VARS['entry_country_id']);

       $entry_company = tep_db_prepare_input($HTTP_POST_VARS['entry_company']);
       if (isset($HTTP_POST_VARS['entry_state'])) {
         $entry_state = tep_db_prepare_input($HTTP_POST_VARS['entry_state']);
       } else {
         $entry_state = '';
       }
       if (isset($HTTP_POST_VARS['entry_zone_id'])) {
         $entry_zone_id = tep_db_prepare_input($HTTP_POST_VARS['entry_zone_id']);
       } else {
         $entry_zone_id = 0;
       }

       if (strlen($customers_firstname) < ENTRY_FIRST_NAME_MIN_LENGTH) {
         $error = true;
         $entry_firstname_error = true;
       } else {
         $entry_firstname_error = false;
       }

       if (strlen($customers_lastname) < ENTRY_LAST_NAME_MIN_LENGTH) {
         $error = true;
         $entry_lastname_error = true;
       } else {
         $entry_lastname_error = false;
       }

       if (strlen($entry_firstname) < ENTRY_FIRST_NAME_MIN_LENGTH) {
         $error = true;
         $entry_entry_firstname_error = true;
       } else {
         $entry_entry_firstname_error = false;
       }

       if (strlen($entry_lastname) < ENTRY_LAST_NAME_MIN_LENGTH) {
         $error = true;
         $entry_entry_lastname_error = true;
       } else {
         $entry_entry_lastname_error = false;
       }

       if (ACCOUNT_DOB == 'true') {
         if ((strlen($customers_dob) >= ENTRY_DOB_MIN_LENGTH) && ((is_numeric(tep_date_raw($customers_dob)) && @checkdate(substr(tep_date_raw($customers_dob), 4, 2), substr(tep_date_raw($customers_dob), 6, 2), substr(tep_date_raw($customers_dob), 0, 4))) || empty($customers_dob))) {
           $entry_date_of_birth_error = false;
         } else {
           $error = true;
           $entry_date_of_birth_error = true;
         }
       }

       if (strlen($customers_email_address) < ENTRY_EMAIL_ADDRESS_MIN_LENGTH) {
         $error = true;
         $entry_email_address_error = true;
       } else {
         $entry_email_address_error = false;
       }

       if (!tep_validate_email($customers_email_address)) {
         $error = true;
         $entry_email_address_check_error = true;
       } else {
         $entry_email_address_check_error = false;
       }

       if (strlen($entry_street_address) < ENTRY_STREET_ADDRESS_MIN_LENGTH) {
         $error = true;
         $entry_street_address_error = true;
       } else {
         $entry_street_address_error = false;
       }

       if (strlen($entry_city) < ENTRY_CITY_MIN_LENGTH) {
         $error = true;
         $entry_city_error = true;
       } else {
         $entry_city_error = false;
       }

       $check_query = tep_db_query("select * from " . TABLE_COUNTRIES . " where countries_id = " . (int)$entry_country_id);
       if (tep_db_num_rows($check_query) == 0) {
         $error = true;
         $entry_country_error = true;
       } else {
         $country = tep_db_fetch_array($check_query);
         $entry_country_error = false;
       }

       $entry_post_code_error = $entry_country_error;
       if (tep_not_null($country['countries_postal_validation'])) { 
         if (!preg_match($country['countries_postal_validation'], $entry_postcode)) {
           $error = true;
           $entry_post_code_error = sprintf(ENTRY_ERROR_POSTCODE, strtolower($country['countries_iso_code_3']), $country['countries_name']);
         }
       }

       if (ACCOUNT_STATE == 'true') {
         if ($entry_country_error == true) {
           $entry_state_error = true;
         } else {
           $entry_state_error = false;
           $check_query = tep_db_query("select count(*) as total from " . TABLE_ZONES . " where zone_country_id = '" . (int)$entry_country_id . "'");
           $check_value = tep_db_fetch_array($check_query);
           $entry_state_has_zones = ($check_value['total'] > 0);
           if ($entry_state_has_zones == true) {
             $zone_query = tep_db_query("select zone_name from " . TABLE_ZONES . " where zone_country_id = '" . (int)$entry_country_id . "' and zone_id = '" . (int)$entry_zone_id . "'");
             if (tep_db_num_rows($zone_query) == 1) {
               $zone = tep_db_fetch_array($zone_query);
               $entry_state = $zone['zone_name'];
             } elseif ($country['requires_state'] == 1) {
               $error = true;
               $entry_state_error = true;
             }
           } else {
             if (($country['requires_state'] == 1) && (strlen($entry_state) < ENTRY_STATE_MIN_LENGTH)) {
               $error = true;
               $entry_state_error = true;
             }
           }
        }
      }

     if (strlen($customers_telephone) < ENTRY_TELEPHONE_MIN_LENGTH) {
       $error = true;
       $entry_telephone_error = ENTRY_TELEPHONE_NUMBER_ERROR;
     } else {
       $entry_telephone_error = false;
     }
     $entry_alt_telephone_error = $entry_fax_error = false;

     $check_query = tep_db_query("select customers_default_address_id from " . TABLE_CUSTOMERS . " where customers_id = " . (int)$customers_id);
     $cdaid = tep_db_fetch_array($check_query);
     if ($cdaid['customers_default_address_id'] != $address_id) {
       $check_query = tep_db_query("select c.countries_iso_code_2 from " . TABLE_COUNTRIES . " c join " . TABLE_ADDRESS_BOOK . " ab where c.countries_id = ab.entry_country_id and ab.customers_id = '" . (int)$customers_id . "' and ab.address_book_id = '" . (int)$cdaid['customers_default_address_id'] . "'");
       $country = tep_db_fetch_array($check_query);
     }
     if (($country['countries_iso_code_2'] == 'US') || ($country['countries_iso_code_2'] == 'CA')) { // format US/Canada phone numbers
       $customers_telephone = format_US_Canada_phone($customers_telephone);
       if ($customers_telephone === false) {
         $error = true;
         $entry_telephone_error =  ENTRY_ERROR_US_CANADA_PHONE;
       }
       if (strlen($customers_alternate_telephone) > 0) $customers_alternate_telephone = format_US_Canada_phone($customers_alternate_telephone);
       if ($customers_alternate_telephone === false) {
         $error = true;
         $entry_alt_telephone_error =  ENTRY_ERROR_US_CANADA_PHONE;
       }
       if (strlen($customers_fax) > 0) $customers_fax = format_US_Canada_phone($customers_fax);
       if ($customers_fax === false) {
         $error = true;
         $entry_fax_error =  ENTRY_ERROR_US_CANADA_PHONE;
       }
     }
     if ($customers_alternate_telephone == $customers_telephone) $customers_alternate_telephone = ''; // dispose of duplicate phone number

     $check_email = tep_db_query("select customers_email_address from " . TABLE_CUSTOMERS . " where customers_email_address = '" . tep_db_input($customers_email_address) . "' and customers_id != '" . (int)$customers_id . "'");
     if (tep_db_num_rows($check_email)) {
       $error = true;
       $entry_email_address_exists = true;
     } else {
       $entry_email_address_exists = false;
     }

     if ($error == false) {

       $sql_data_array = array('customers_firstname' => $customers_firstname,
                               'customers_lastname' => $customers_lastname,
                               'customers_email_address' => $customers_email_address,
                               'customers_telephone' => $customers_telephone,
                               'customers_alternate_telephone' => (tep_not_null($customers_alternate_telephone) ? $customers_alternate_telephone : 'null'),
                               'customers_fax' => (tep_not_null($customers_fax) ? $customers_fax : 'null'),
                               // FWR TAX EXEMPT
                               'customers_tax_exempt' => $customers_tax_exempt,
                               'customers_tax_exempt_id' => $customers_tax_exempt_id,
                               'customers_org_type' => $customers_org_type,
                               // END FWR TAX EXEMPT
                               'customers_newsletter' => $customers_newsletter);

       if (ACCOUNT_GENDER == 'true') $sql_data_array['customers_gender'] = $customers_gender;
       if (ACCOUNT_DOB == 'true') $sql_data_array['customers_dob'] = tep_date_raw($customers_dob);

       tep_db_perform(TABLE_CUSTOMERS, $sql_data_array, 'update', "customers_id = '" . (int)$customers_id . "'");

       tep_db_query("update " . TABLE_CUSTOMERS_INFO . " set customers_info_date_account_last_modified = now() where customers_info_id = '" . (int)$customers_id . "'");

       if ($entry_state == '') $entry_state = 'null';

       $sql_data_array = array('entry_firstname' => $entry_firstname,
                               'entry_lastname' => $entry_lastname,
                               'entry_street_address' => $entry_street_address,
                               'entry_address2' => (tep_not_null($entry_address2) ? $entry_address2 : 'null'),
                               'entry_postcode' => $entry_postcode,
                               'entry_city' => $entry_city,
                               'entry_country_id' => $entry_country_id);

       if (ACCOUNT_COMPANY == 'true') $sql_data_array['entry_company'] = (tep_not_null($entry_company) ? $entry_company : 'null');
       if (ACCOUNT_SUBURB == 'true') $sql_data_array['entry_suburb'] = (tep_not_null($entry_suburb) ? $entry_suburb : 'null');

       if (ACCOUNT_STATE == 'true') {
         if ($entry_zone_id > 0) {
           $sql_data_array['entry_zone_id'] = $entry_zone_id;
           $sql_data_array['entry_state'] = $entry_state;
         } else {
           $sql_data_array['entry_zone_id'] = '0';
           $sql_data_array['entry_state'] = $entry_state;
         }
       }

       tep_db_perform(TABLE_ADDRESS_BOOK, $sql_data_array, 'update', "customers_id = '" . (int)$customers_id . "' and address_book_id = '" . (int)$address_id . "'");

       tep_redirect(tep_href_link(FILENAME_CUSTOMERS, tep_get_all_get_params(array('cID', 'action', 'aid')) . 'cID=' . $customers_id));

       } else if ($error == true) {
         $cInfo = new objectInfo($HTTP_POST_VARS);
         $processed = true;
       }

       break;
     case 'deleteconfirm':
       $customers_id = tep_db_prepare_input($HTTP_GET_VARS['cID']);

       if (isset($HTTP_POST_VARS['delete_reviews']) && ($HTTP_POST_VARS['delete_reviews'] == 'on')) {
         $reviews_query = tep_db_query("select reviews_id from " . TABLE_REVIEWS . " where customers_id = '" . (int)$customers_id . "'");
         while ($reviews = tep_db_fetch_array($reviews_query)) {
           tep_db_query("delete from " . TABLE_REVIEWS_DESCRIPTION . " where reviews_id = '" . (int)$reviews['reviews_id'] . "'");
         }

         tep_db_query("delete from " . TABLE_REVIEWS . " where customers_id = '" . (int)$customers_id . "'");
       } else {
         tep_db_query("update " . TABLE_REVIEWS . " set customers_id = null where customers_id = '" . (int)$customers_id . "'");
       }

       tep_db_query("delete from " . TABLE_ADDRESS_BOOK . " where customers_id = '" . (int)$customers_id . "'");
       tep_db_query("delete from " . TABLE_CUSTOMERS . " where customers_id = '" . (int)$customers_id . "'");
       tep_db_query("delete from " . TABLE_CUSTOMERS_INFO . " where customers_info_id = '" . (int)$customers_id . "'");
       tep_db_query("delete from " . TABLE_CUSTOMERS_BASKET . " where customers_id = '" . (int)$customers_id . "'");
       tep_db_query("delete from " . TABLE_CUSTOMERS_BASKET_ATTRIBUTES . " where customers_id = '" . (int)$customers_id . "'");
// Wishlist addition to delete products from the wishlist when customer deleted
//       tep_db_query("delete from " . TABLE_WISHLIST . " where customers_id = " . (int)$customers_id);
 //      tep_db_query("delete from " . TABLE_WISHLIST_ATTRIBUTES . " where customers_id = " . (int)$customers_id);
 //      tep_db_query("delete from " . TABLE_WHOS_ONLINE . " where customer_id = '" . (int)$customers_id . "'");

       tep_redirect(tep_href_link(FILENAME_CUSTOMERS, tep_get_all_get_params(array('cID', 'action'))));
       break;
     default:
       $customers_query = tep_db_query("select c.customers_id, c.customers_gender, c.customers_firstname, c.customers_lastname, c.customers_dob, c.customers_email_address, a.entry_firstname, a.entry_lastname, a.entry_company, a.entry_street_address, a.entry_address2, a.entry_suburb, a.entry_postcode, a.entry_city, a.entry_state, a.entry_zone_id, a.entry_country_id, c.customers_telephone, c.customers_alternate_telephone, c.customers_fax, c.customers_newsletter, c.customers_default_address_id, c.customers_default_billing_address_id, c.customers_default_shipping_address_id from " . TABLE_CUSTOMERS . " c left join " . TABLE_ADDRESS_BOOK . " a on a.customers_id = c.customers_id where a.address_book_id = " . (int)$address_id . " and c.customers_id = '" . (int)$customers_id . "'");
       $customers = tep_db_fetch_array($customers_query);
       $cInfo = new objectInfo($customers);
   }
 }

 require(DIR_WS_INCLUDES . 'template_top.php');

?>

   <table border="0" width="100%" cellspacing="0" cellpadding="2">
<?php
 if ($action == 'newpwd') {
?>
     <tr>
       <td><table border="0" width="100%" cellspacing="0" cellpadding="0">
         <tr>
           <td class="pageHeading"><?php echo HEADING_TITLE; ?></td>
           <td class="pageHeading" align="right"><?php echo tep_draw_separator('pixel_trans.gif', HEADING_IMAGE_WIDTH, HEADING_IMAGE_HEIGHT); ?></td>
         </tr>
       </table></td>
     </tr>
     <tr>
       <td class="main"><?php echo '<strong>' . HEADING_CHANGE_PWD . $cInfo->customers_firstname . ' ' . $cInfo->customers_lastname . '</strong><br />' . $cInfo->customers_email_address; ?></td>
     </tr>
     <tr>
       <td class="main"><?php echo tep_draw_form('newpwd', FILENAME_CUSTOMERS, tep_get_all_get_params(array('action')) . 'action=savepwd', 'post') . ENTRY_NEW_PWD . tep_draw_input_field('pwd', null, 'size="32"'); ?></td>
     </tr>
     <tr>
       <td class="main"><?php echo TEXT_PWD_WARNING; ?></td>
     </tr>
     <tr>
       <td class="main"><?php echo tep_draw_button(IMAGE_SAVE, 'disk') . tep_draw_button(IMAGE_CANCEL, 'cancel', tep_href_link(FILENAME_CUSTOMERS, tep_get_all_get_params(array('action', 'aid'))), 'primary'); ?></td>
     </tr>
<?php
 } elseif ($action == 'edit' || $action == 'update') {
   // FWR TAX EXEMPT
   $customers_query = tep_db_query("select c.customers_gender, c.customers_firstname, c.customers_org_type, c.customers_lastname, c.customers_tax_exempt, c.customers_tax_exempt_id, c.customers_dob, c.customers_email_address, a.entry_company, a.entry_street_address, a.entry_suburb, a.entry_postcode, a.entry_city, a.entry_state, a.entry_zone_id, a.entry_country_id, c.customers_telephone, c.customers_fax, c.customers_newsletter, c.customers_default_address_id from " . TABLE_CUSTOMERS . " c left join " . TABLE_ADDRESS_BOOK . " a on c.customers_default_address_id = a.address_book_id where a.customers_id = c.customers_id and c.customers_id = '" . $HTTP_GET_VARS['cID'] . "'");
   $customers = tep_db_fetch_array($customers_query);
   $cInfo = new objectInfo($customers);
 // END FWR TAX EXEMPT
   $newsletter_array = array(array('id' => '1', 'text' => ENTRY_NEWSLETTER_YES),
                             array('id' => '0', 'text' => ENTRY_NEWSLETTER_NO));
   // FWR TAX EXEMPT
   $tax_exempt_array = array(
                       array('id' => '0',
                             'text' => ENTRY_TAX_EXEMPT_NO),
                       array('id' => '1',
                             'text' => ENTRY_TAX_EXEMPT_YES));
 // END FWR TAX EXEMPT
?>
     <tr>
       <td><table border="0" width="100%" cellspacing="0" cellpadding="0">
         <tr>
           <td class="pageHeading"><?php echo HEADING_TITLE; ?></td>
           <td class="pageHeading" align="right"><?php echo tep_draw_separator('pixel_trans.gif', HEADING_IMAGE_WIDTH, HEADING_IMAGE_HEIGHT); ?></td>
         </tr>
       </table></td>
     </tr>
<?php
 $customer_address_query = tep_db_query("select address_book_id as id from " . TABLE_ADDRESS_BOOK . " where customers_id = '" . (int)$customers_id . "'");
 if (tep_db_num_rows($customer_address_query) > 1) {
?>
     <tr>
       <td><?php echo tep_draw_separator('pixel_trans.gif', '1', '10'); ?></td>
     </tr>
     <tr>
       <td class="formAreaTitle"><?php echo TEXT_CLICK_TO_EDIT; ?></td>
     </tr>
     <tr>
       <td class="formArea"><table border="0" cellspacing="2" cellpadding="2">
         <tr>
<?php
   $col = 0;
   while ($address = tep_db_fetch_array($customer_address_query)) {
     $col++;
     if ($col > 4) {
       $col = 1;
       echo "</tr>\n<tr>";
     }
     if ($address['id'] == $address_id) {
       echo '<td class="smallText" style="border: 1px solid red; padding: 2px;">';
     } else {
       echo '<td class="smallText" style="border: 1px solid black; padding: 2px;">';
     }
     if ($address['id'] == $default_addresses['customers_default_address_id']) echo '<em style="color: blue">' . TEXT_DEFAULT . TEXT_MAILING . '</em><br />';
     if ($address['id'] == $default_addresses['customers_default_billing_address_id']) echo '<em style="color: blue">' . TEXT_DEFAULT . TEXT_BILLING . '</em><br />';
     if ($address['id'] == $default_addresses['customers_default_shipping_address_id']) echo '<em style="color: blue">' . TEXT_DEFAULT . TEXT_SHIPPING . '</em><br />';
     echo '<a href="' . tep_href_link(FILENAME_CUSTOMERS, tep_get_all_get_params(array('cID', 'action', 'aid')) . 'cID=' . $cInfo->customers_id . '&action=edit&aid=' . $address['id']) . (($address['id'] == $address_id) ? '" style="color: red">' : '">') . address_label($customers_id, $address['id']) . '</a>';
     if ($address['id'] != $default_addresses['customers_default_address_id']) echo '<br /><a style="color: blue" href="' . tep_href_link(FILENAME_CUSTOMERS, tep_get_all_get_params(array('cID', 'action', 'aid')) . 'cID=' . $cInfo->customers_id . '&action=setdefault&type=M&aid=' . $address['id']) . '">' . TEXT_SET_DEFAULT . TEXT_MAILING . '</a>';
     if ($address['id'] != $default_addresses['customers_default_billing_address_id']) echo '<br /><a style="color: blue" href="' . tep_href_link(FILENAME_CUSTOMERS, tep_get_all_get_params(array('cID', 'action', 'aid')) . 'cID=' . $cInfo->customers_id . '&action=setdefault&type=B&aid=' . $address['id']) . '">' . TEXT_SET_DEFAULT . TEXT_BILLING . '</a>';
     if ($address['id'] != $default_addresses['customers_default_shipping_address_id']) echo '<br /><a style="color: blue" href="' . tep_href_link(FILENAME_CUSTOMERS, tep_get_all_get_params(array('cID', 'action', 'aid')) . 'cID=' . $cInfo->customers_id . '&action=setdefault&type=S&aid=' . $address['id']) . '">' . TEXT_SET_DEFAULT . TEXT_SHIPPING . '</a>';
     if (!in_array($address['id'], $default_addresses)) echo '<br /><br /><a style="color: maroon" href="' . tep_href_link(FILENAME_CUSTOMERS, tep_get_all_get_params(array('cID', 'action', 'aid')) . 'cID=' . $cInfo->customers_id . '&action=deladdress&aid=' . $address['id']) . '">' . TEXT_DELETE_ADDRESS . '</a>';
     echo "</td>\n";
   }
?>
         </tr>
       </table></td>
     </tr>
<?php
 }
?>
     <tr>
       <td><?php echo tep_draw_separator('pixel_trans.gif', '1', '10'); ?></td>
     </tr>
     <tr><?php echo tep_draw_form('customers', FILENAME_CUSTOMERS, tep_get_all_get_params(array('action', 'aid')) . 'action=update&aid=' . (tep_not_null($address_id) ? $address_id : $cInfo->customers_default_address_id), 'post'); ?>
       <td class="formAreaTitle"><?php echo CATEGORY_PERSONAL; ?></td>
     </tr>
     <tr>
       <td class="formArea"><table border="0" cellspacing="2" cellpadding="2">
<?php
   if (ACCOUNT_GENDER == 'true') {
?>
         <tr>
           <td class="main"><?php echo ENTRY_GENDER; ?></td>
           <td class="main">
<?php
   if ($error == true) {
     if ($entry_gender_error == true) {
       echo tep_draw_radio_field('customers_gender', 'm', false, $cInfo->customers_gender) . '  ' . MALE . '  ' . tep_draw_radio_field('customers_gender', 'f', false, $cInfo->customers_gender) . '  ' . FEMALE . ' ' . ENTRY_GENDER_ERROR;
     } else {
       echo ($cInfo->customers_gender == 'm') ? MALE : FEMALE;
       echo tep_draw_hidden_field('customers_gender');
     }
   } else {
     echo tep_draw_radio_field('customers_gender', 'm', false, $cInfo->customers_gender) . '  ' . MALE . '  ' . tep_draw_radio_field('customers_gender', 'f', false, $cInfo->customers_gender) . '  ' . FEMALE;
   }
?></td>
         </tr>
<?php
   }
?>
         <tr>
           <td class="main"><?php echo ENTRY_FIRST_NAME; ?></td>
           <td class="main">
<?php
 if ($error == true) {
   if ($entry_firstname_error == true) {
     echo tep_draw_input_field('customers_firstname', $cInfo->customers_firstname, 'size="64"') . ' ' . ENTRY_FIRST_NAME_ERROR;
   } else {
     echo $cInfo->customers_firstname . tep_draw_hidden_field('customers_firstname');
   }
 } else {
   echo tep_draw_input_field('customers_firstname', $cInfo->customers_firstname, 'size="64"', true);
 }
?></td>
         </tr>
         <tr>
           <td class="main"><?php echo ENTRY_LAST_NAME; ?></td>
           <td class="main">
<?php
 if ($error == true) {
   if ($entry_lastname_error == true) {
     echo tep_draw_input_field('customers_lastname', $cInfo->customers_lastname, 'size="64"') . ' ' . ENTRY_LAST_NAME_ERROR;
   } else {
     echo $cInfo->customers_lastname . tep_draw_hidden_field('customers_lastname');
   }
 } else {
   echo tep_draw_input_field('customers_lastname', $cInfo->customers_lastname, 'size="64"', true);
 }
?></td>
         </tr>
<?php
   if (ACCOUNT_DOB == 'true') {
?>
         <tr>
           <td class="main"><?php echo ENTRY_DATE_OF_BIRTH; ?></td>
           <td class="main">
<?php
   if ($error == true) {
     if ($entry_date_of_birth_error == true) {
       echo tep_draw_input_field('customers_dob', tep_date_short($cInfo->customers_dob), 'size="64"') . ' ' . ENTRY_DATE_OF_BIRTH_ERROR;
     } else {
       echo $cInfo->customers_dob . tep_draw_hidden_field('customers_dob');
     }
   } else {
     echo tep_draw_input_field('customers_dob', tep_date_short($cInfo->customers_dob), 'size="64" id="customers_dob"', true);
   }
?>
             <script type="text/javascript">$('#customers_dob').datepicker({dateFormat: '<?php echo JQUERY_DATEPICKER_FORMAT; ?>', changeMonth: true, changeYear: true, yearRange: '-100:+0'});</script>
           </td>
         </tr>
<?php
   }
?>
         <tr>
           <td class="main"><?php echo ENTRY_EMAIL_ADDRESS; ?></td>
           <td class="main">
<?php
 if ($error == true) {
   if ($entry_email_address_error == true) {
     echo tep_draw_input_field('customers_email_address', $cInfo->customers_email_address, 'size="64"') . ' ' . ENTRY_EMAIL_ADDRESS_ERROR;
   } elseif ($entry_email_address_check_error == true) {
     echo tep_draw_input_field('customers_email_address', $cInfo->customers_email_address, 'size="64"') . ' ' . ENTRY_EMAIL_ADDRESS_CHECK_ERROR;
   } elseif ($entry_email_address_exists == true) {
     echo tep_draw_input_field('customers_email_address', $cInfo->customers_email_address, 'size="64"') . ' ' . ENTRY_EMAIL_ADDRESS_ERROR_EXISTS;
   } else {
     echo $customers_email_address . tep_draw_hidden_field('customers_email_address');
   }
 } else {
   echo tep_draw_input_field('customers_email_address', $cInfo->customers_email_address, 'size="64"', true);
 }
?></td>
         </tr>
       </table></td>
     </tr>
     <tr>
       <td><?php echo tep_draw_separator('pixel_trans.gif', '1', '10'); ?></td>
     </tr>
     <tr>
       <td class="formAreaTitle"><?php echo CATEGORY_ADDRESS; ?></td>
     </tr>
     <tr>
       <td class="formArea"><table border="0" cellspacing="2" cellpadding="2">
         <tr>
           <td class="main"><?php echo ENTRY_FIRST_NAME; ?></td>
           <td class="main">
<?php
 if ($error == true) {
   if ($entry_entry_firstname_error == true) {
     echo tep_draw_input_field('entry_firstname', $cInfo->entry_firstname, 'size="64"') . ' ' . ENTRY_FIRST_NAME_ERROR;
   } else {
     echo $cInfo->entry_firstname . tep_draw_hidden_field('entry_firstname');
   }
 } else {
   echo tep_draw_input_field('entry_firstname', $cInfo->entry_firstname, 'size="64"', true);
 }
?></td>
         </tr>
         <tr>
           <td class="main"><?php echo ENTRY_LAST_NAME; ?></td>
           <td class="main">
<?php
 if ($error == true) {
   if ($entry_entry_lastname_error == true) {
     echo tep_draw_input_field('entry_lastname', $cInfo->entry_lastname, 'size="64"') . ' ' . ENTRY_LAST_NAME_ERROR;
   } else {
     echo $cInfo->entry_lastname . tep_draw_hidden_field('entry_lastname');
   }
 } else {
   echo tep_draw_input_field('entry_lastname', $cInfo->entry_lastname, 'size="64"', true);
 }
?></td>
         </tr>
<?php
   if (ACCOUNT_COMPANY == 'true') {
?>
         <tr>
           <td class="main"><?php echo ENTRY_COMPANY; ?></td>
           <td class="main">
<?php
   if ($error == true) {
     echo $cInfo->entry_company . tep_draw_hidden_field('entry_company');
   } else {
     echo tep_draw_input_field('entry_company', $cInfo->entry_company, 'size="64"');
   }
?></td>
<?php //FWR TAX EXEMPT ?>
         </tr>
         <tr>
           <td class="main"><?php echo ENTRY_TAX_EXEMPT; ?></td>
           <td class="main"><?php echo tep_draw_pull_down_menu('tax_exempt', $tax_exempt_array, $cInfo->customers_tax_exempt); ?></td>
         </tr>
         <tr>
           <td class="main"><?php echo ENTRY_TAX_EXEMPT_ID; ?></td>
           <td class="main"><?php echo tep_draw_input_field('tax_exempt_id', $cInfo->customers_tax_exempt_id); ?></td>
         </tr>
         <tr>
           <td class="main"><?php echo ENTRY_ORG_TYPE; ?></td>
           <td class="main">
<?php

   $org_type_query = tep_db_query("select org_type_id, org_type_title from " . TABLE_ORGANIZATION_TYPE . " order by org_type_title");
   while ($org_type_row = tep_db_fetch_array($org_type_query)) {
     $org_type_array[] = array('id' => $org_type_row['org_type_id'], 'text' => $org_type_row['org_type_title']);
   }

   echo tep_draw_pull_down_menu('org_type', $org_type_array, $cInfo->customers_org_type );

?>
<?php // END FWR TAX EXEMPT ?>
         </tr>
<?php
   }
?>
         <tr>
           <td class="main"><?php echo ENTRY_STREET_ADDRESS; ?></td>
           <td class="main">
<?php
 if ($error == true) {
   if ($entry_street_address_error == true) {
     echo tep_draw_input_field('entry_street_address', $cInfo->entry_street_address, 'size="64"') . ' ' . ENTRY_STREET_ADDRESS_ERROR;
   } else {
     echo $cInfo->entry_street_address . tep_draw_hidden_field('entry_street_address');
   }
 } else {
   echo tep_draw_input_field('entry_street_address', $cInfo->entry_street_address, 'size="64"', true);
 }
?></td>
         </tr>
         <tr>
           <td class="main"><?php echo ENTRY_ADDRESS2; ?></td>
           <td class="main">
<?php
 if ($error == true) {
   echo $cInfo->entry_address2 . tep_draw_hidden_field('entry_address2');
 } else {
   echo tep_draw_input_field('entry_address2', $cInfo->entry_address2, 'size="64"');
 }
?></td>
         </tr>
<?php
   if (ACCOUNT_SUBURB == 'true') {
?>
         <tr>
           <td class="main"><?php echo ENTRY_SUBURB; ?></td>
           <td class="main">
<?php
   if ($error == true) {
     echo $cInfo->entry_suburb . tep_draw_hidden_field('entry_suburb');
   } else {
     echo tep_draw_input_field('entry_suburb', $cInfo->entry_suburb, 'size="64"');
   }
?></td>
         </tr>
<?php
   }
  $countries_query = tep_db_query("select countries_id, countries_name, requires_state, countries_postal_validation from " . TABLE_COUNTRIES . " order by countries_name");
  $countries = $cl = $rs = array();
  $rpc = '';
  while ($country = tep_db_fetch_array($countries_query)) {
    $cl[] = $country['countries_id'];
    $rs[$country['countries_id']] = $country['requires_state'];
    $rpc .= '<span id="pc' . $country['countries_id'] . '"' . ($country['countries_id'] == $cInfo->entry_country_id ? '' : ' style="display:none"') . '>' . (tep_not_null($country['countries_postal_validation']) ? TEXT_FIELD_REQUIRED : '') . "</span>\n";
    $countries[] = array('id' => $country['countries_id'],
                         'text' => $country['countries_name']);
  }
?>
         <tr>
           <td class="main"><?php echo ENTRY_POST_CODE; ?></td>
           <td class="main">
<?php
 if ($error == true) {
   if ($entry_post_code_error !== false) {
     echo tep_draw_input_field('entry_postcode', $cInfo->entry_postcode, 'size="64"') . ' ' . $entry_post_code_error;
   } else {
     echo $cInfo->entry_postcode . tep_draw_hidden_field('entry_postcode');
   }
 } else {
   echo tep_draw_input_field('entry_postcode', $cInfo->entry_postcode, 'size="64"');
 }
 echo $rpc;
?></td>
         </tr>
         <tr>
           <td class="main"><?php echo ENTRY_CITY; ?></td>
           <td class="main">
<?php
 if ($error == true) {
   if ($entry_city_error == true) {
     echo tep_draw_input_field('entry_city', $cInfo->entry_city, 'size="64"') . ' ' . ENTRY_CITY_ERROR;
   } else {
     echo $cInfo->entry_city . tep_draw_hidden_field('entry_city');
   }
 } else {
   echo tep_draw_input_field('entry_city', $cInfo->entry_city, 'size="64"', true);
 }
?></td>
         </tr>
<?php
   if (ACCOUNT_STATE == 'true') {
?>
         <tr>
           <td class="main"><?php echo ENTRY_STATE; ?></td>
           <td class="main">
<?php
   $entry_state = tep_get_zone_name($cInfo->entry_country_id, $cInfo->entry_zone_id, $cInfo->entry_state);
   if ($error == true) {
     if ($entry_state_error == true) {
       if ($entry_state_has_zones == true) {
         $zones_array = array();
         $zones_query = tep_db_query("select zone_name, zone_id from " . TABLE_ZONES . " where zone_country_id = '" . tep_db_input($cInfo->entry_country_id) . "' order by zone_name");
         while ($zones_values = tep_db_fetch_array($zones_query)) {
           $zones_array[] = array('id' => $zones_values['zone_id'],
                                  'text' => $zones_values['zone_name']);
         }
         echo tep_draw_pull_down_menu('entry_zone_id', $zones_array, $cInfo->entry_zone_id) . ' ' . ENTRY_STATE_ERROR;
       } else {
         echo tep_draw_input_field('entry_state', $entry_state, 'size="64"') . ' ' . ENTRY_STATE_ERROR;
       }
     } else {
       echo $entry_state . tep_draw_hidden_field('entry_zone_id') . tep_draw_hidden_field('entry_state');
     }
   } else {
     foreach ($cl as $id) {
       if ($id != $cInfo->entry_country_id) { //if current list is not for selected country set list to not displayed and disabled
         $parms = 'disabled="disabled" ';
         $span = '<span style="display:none" id="sp' . $id .'">';
       } else {
         $parms = '';
         $span = '<span id="sp' . $id .'">';
       }
       $parms .= 'id="' . $id . '"'; // set id for list for javascript show/hide process
       echo $span;
       $zones_array = array();
       $zones_query = tep_db_query("select zone_name, zone_id from " . TABLE_ZONES . " where zone_country_id = '" . (int)$id . "' order by zone_name");
       if (tep_db_num_rows($zones_query) == 0) { // if no zones for country draw text field
         echo tep_draw_input_field('entry_state', $entry_state, $parms . ' size="64"');
       } else { // otherwise draw pulldown list of zones
         while ($zones_values = tep_db_fetch_array($zones_query)) {
           $zones_array[] = array('id' => $zones_values['zone_id'],
                                  'text' => $zones_values['zone_name']);
         }
         echo tep_draw_pull_down_menu('entry_zone_id', $zones_array, $cInfo->entry_zone_id, $parms);
       }      
       if ($rs[$id] == 1) echo TEXT_FIELD_REQUIRED;
       echo "</span>\n";
     }
   }

?></td>
        </tr>
<?php
   }
?>
<!-- hide and disable all state lists and postal code requirements before showing list pertaining to currently chosen country //-->
<script language="Javascript">
 function ShowNewList(){
   var id = new Array(<?php echo implode(', ', $cl); ?>);
   var x, item;
   for (x = 0; x < id.length; x++) {
<?php
   if (ACCOUNT_STATE == 'true') {
?>
     item = document.getElementById(id[x]);
     if (item) { item.disabled = true; }
     item = document.getElementById('sp' + id[x]);
     if (item) { item.style.display = 'none'; }
<?php
   }
?>
     item = document.getElementById('pc' + id[x]);
     if (item) { item.style.display = 'none'; }
   }   
   var pm = document.getElementById('ctry');
   id = pm.value;
<?php
   if (ACCOUNT_STATE == 'true') {
?>
   item = document.getElementById(id);
   item.disabled = false;
   item = document.getElementById('sp' + id);
   item.style.display = '';
<?php
   }
?>
   item = document.getElementById('pc' + id);
   item.style.display = '';
 }
</script>
         <tr>
           <td class="main"><?php echo ENTRY_COUNTRY; ?></td>
           <td class="main">
<?php
 if ($error == true) {
   if ($entry_country_error == true) {
     echo tep_draw_pull_down_menu('entry_country_id', $countries, $cInfo->entry_country_id, 'id="ctry" onchange="ShowNewList()"', true) . ' ' . ENTRY_COUNTRY_ERROR;
   } else {
     echo tep_get_country_name($cInfo->entry_country_id) . tep_draw_hidden_field('entry_country_id');
   }
 } else {
   echo tep_draw_pull_down_menu('entry_country_id', $countries, $cInfo->entry_country_id, 'id="ctry" onchange="ShowNewList()"', true);
 }
?></td>
         </tr>
       </table></td>
     </tr>
     <tr>
       <td><?php echo tep_draw_separator('pixel_trans.gif', '1', '10'); ?></td>
     </tr>
     <tr>
       <td class="formAreaTitle"><?php echo CATEGORY_CONTACT; ?></td>
     </tr>
     <tr>
       <td class="formArea"><table border="0" cellspacing="2" cellpadding="2">
         <tr>
           <td class="main"><?php echo ENTRY_TELEPHONE_NUMBER; ?></td>
           <td class="main">
<?php
 if ($error == true) {
   if ($entry_telephone_error !== false) {
     echo tep_draw_input_field('customers_telephone', $cInfo->customers_telephone, 'size="32"') . ' ' . $entry_telephone_error;
   } else {
     echo $cInfo->customers_telephone . tep_draw_hidden_field('customers_telephone');
   }
 } else {
   echo tep_draw_input_field('customers_telephone', $cInfo->customers_telephone, 'size="32"', true);
 }
?></td>
         </tr>
         <tr>
           <td class="main"><?php echo ENTRY_ALTERNATE_TELEPHONE; ?></td>
           <td class="main">
<?php
 if ($error == true) {
   if ($entry_alt_telephone_error !== false) {
     echo tep_draw_input_field('customers_alternate_telephone', $cInfo->customers_alternate_telephone, 'size="32"') . ' ' . $entry_alt_telephone_error;
   } else {
     echo $cInfo->customers_alternate_telephone . tep_draw_hidden_field('customers_alternate_telephone');
   }
 } else {
   echo tep_draw_input_field('customers_alternate_telephone', $cInfo->customers_alternate_telephone, 'size="32"');
 }
?></td>
         </tr>
         <tr>
           <td class="main"><?php echo ENTRY_FAX_NUMBER; ?></td>
           <td class="main">
<?php
 if ($error == true) {
   if ($entry_fax_error !== false) {
     echo tep_draw_input_field('customers_fax', $cInfo->customers_fax, 'size="32"') . ' ' . $entry_fax_error;
   } else {
     echo $cInfo->customers_fax . tep_draw_hidden_field('customers_fax');
   }
 } else {
   echo tep_draw_input_field('customers_fax', $cInfo->customers_fax, 'size="32"');
 }
?></td>
         </tr>
       </table></td>
     </tr>
     <tr>
       <td><?php echo tep_draw_separator('pixel_trans.gif', '1', '10'); ?></td>
     </tr>
     <tr>
       <td class="formAreaTitle"><?php echo CATEGORY_OPTIONS; ?></td>
     </tr>
     <tr>
       <td class="formArea"><table border="0" cellspacing="2" cellpadding="2">
         <tr>
           <td class="main"><?php echo ENTRY_NEWSLETTER; ?></td>
           <td class="main">
<?php
 if ($processed == true) {
   if ($cInfo->customers_newsletter == '1') {
     echo ENTRY_NEWSLETTER_YES;
   } else {
     echo ENTRY_NEWSLETTER_NO;
   }
   echo tep_draw_hidden_field('customers_newsletter');
 } else {
   echo tep_draw_pull_down_menu('customers_newsletter', $newsletter_array, (($cInfo->customers_newsletter == '1') ? '1' : '0'));
 }
?></td>
         </tr>
       </table></td>
     </tr>
     <tr>
       <td><?php echo tep_draw_separator('pixel_trans.gif', '1', '10'); ?></td>
     </tr>
     <tr>
       <td align="right" class="smallText"><?php echo tep_draw_button(IMAGE_SAVE, 'disk', null, 'primary') . tep_draw_button(IMAGE_CANCEL, 'close', tep_href_link(FILENAME_CUSTOMERS, tep_get_all_get_params(array('action', 'aid')))); ?></td>
     </tr></form>
<?php
 } else {
?>
     <tr>
       <td><table border="0" width="100%" cellspacing="0" cellpadding="0">
         <tr><?php echo tep_draw_form('search', FILENAME_CUSTOMERS, '', 'get'); ?>
           <td class="pageHeading"><?php echo HEADING_TITLE; ?></td>
           <td class="pageHeading" align="right"><?php echo tep_draw_separator('pixel_trans.gif', 1, HEADING_IMAGE_HEIGHT); ?></td>
           <td class="smallText" align="right"><?php echo HEADING_TITLE_SEARCH . ' ' . tep_draw_input_field('search'); ?></td>
         <?php echo tep_hide_session_id(); ?></form></tr>
       </table></td>
     </tr>
     <tr>
       <td><table border="0" width="100%" cellspacing="0" cellpadding="0">
         <tr>
           <td valign="top"><table border="0" width="100%" cellspacing="0" cellpadding="2">
             <tr class="dataTableHeadingRow">
               <td class="dataTableHeadingContent"><?php echo TABLE_HEADING_LASTNAME; ?></td>
               <td class="dataTableHeadingContent"><?php echo TABLE_HEADING_FIRSTNAME; ?></td>
               <?php //FWR TAX EXEMPT ?>
               <td class="dataTableHeadingContent"><?php echo TABLE_HEADING_COMPANY; ?></td>
               <?php // END FWR TAX EXEMPT ?>
               <td class="dataTableHeadingContent"><?php echo TABLE_HEADING_EMAIL; ?></td>
               <td class="dataTableHeadingContent" align="right"><?php echo TABLE_HEADING_ACCOUNT_CREATED; ?></td>
               <td class="dataTableHeadingContent" align="right"><?php echo TABLE_HEADING_ACTION; ?> </td>
             </tr>
<?php
   $search = '';
   if (isset($HTTP_GET_VARS['search']) && tep_not_null($HTTP_GET_VARS['search'])) {
     $keywords = tep_db_input(tep_db_prepare_input($HTTP_GET_VARS['search']));
     $search = "where c.customers_lastname like '%" . $keywords . "%' or c.customers_firstname like '%" . $keywords . "%' or c.customers_email_address like '%" . $keywords . "%'";
   }
   // FWR TAX EXEMPT
   $customers_query_raw = "select c.customers_id, c.customers_lastname, c.customers_firstname, c.customers_org_type, c.customers_email_address, a.entry_country_id from " . TABLE_CUSTOMERS . " c left join " . TABLE_ADDRESS_BOOK . " a on c.customers_id = a.customers_id and c.customers_default_address_id = a.address_book_id " . $search . " order by c.customers_lastname, c.customers_firstname";
 // END FWR TAX EXEMPT
   $customers_split = new splitPageResults($HTTP_GET_VARS['page'], MAX_DISPLAY_SEARCH_RESULTS, $customers_query_raw, $customers_query_numrows);
   $customers_query = tep_db_query($customers_query_raw);
   while ($customers = tep_db_fetch_array($customers_query)) {
     $info_query = tep_db_query("select customers_info_date_account_created as date_account_created, customers_info_date_account_last_modified as date_account_last_modified, customers_info_date_of_last_logon as date_last_logon, customers_info_number_of_logons as number_of_logons from " . TABLE_CUSTOMERS_INFO . " where customers_info_id = '" . $customers['customers_id'] . "'");
     $info = tep_db_fetch_array($info_query);

     // FWR TAX EXEMPT
 $abook_query = tep_db_query("select entry_company from " . TABLE_ADDRESS_BOOK . " where customers_id = " . $customers['customers_id']);
 $abook = tep_db_fetch_array($abook_query);
 // END FWR TAX EXEMPT

     if ((!isset($HTTP_GET_VARS['cID']) || (isset($HTTP_GET_VARS['cID']) && ($HTTP_GET_VARS['cID'] == $customers['customers_id']))) && !isset($cInfo)) {
       $country_query = tep_db_query("select countries_name from " . TABLE_COUNTRIES . " where countries_id = '" . (int)$customers['entry_country_id'] . "'");
       $country = tep_db_fetch_array($country_query);

       $reviews_query = tep_db_query("select count(*) as number_of_reviews from " . TABLE_REVIEWS . " where customers_id = '" . (int)$customers['customers_id'] . "'");
       $reviews = tep_db_fetch_array($reviews_query);

       $customer_info = array_merge($country, $info, $reviews);

       $cInfo_array = array_merge($customers, $customer_info);
       $cInfo = new objectInfo($cInfo_array);
     }

     if (isset($cInfo) && is_object($cInfo) && ($customers['customers_id'] == $cInfo->customers_id)) {
       echo '          <tr id="defaultSelected" class="dataTableRowSelected" onmouseover="rowOverEffect(this)" onmouseout="rowOutEffect(this)" onclick="document.location.href=\'' . tep_href_link(FILENAME_CUSTOMERS, tep_get_all_get_params(array('cID', 'action')) . 'cID=' . $cInfo->customers_id . '&action=edit') . '\'">' . "\n";
     } else {
       echo '          <tr class="dataTableRow" onmouseover="rowOverEffect(this)" onmouseout="rowOutEffect(this)" onclick="document.location.href=\'' . tep_href_link(FILENAME_CUSTOMERS, tep_get_all_get_params(array('cID')) . 'cID=' . $customers['customers_id']) . '\'">' . "\n";
     }
?>
               <td class="dataTableContent"><?php echo $customers['customers_lastname']; ?></td>
               <td class="dataTableContent"><?php echo $customers['customers_firstname']; ?></td>
               <?php //FWR TAX EXEMPT ?>
               <td class="dataTableContent"><?php echo $abook['entry_company']; ?></td>
<?php // END FWR TAX EXEMPT ?>
               <td class="dataTableContent"><?php echo $customers['customers_email_address']; ?></td>
               <td class="dataTableContent" align="right"><?php echo tep_date_short($info['date_account_created']); ?></td>
               <td class="dataTableContent" align="right"><?php if (isset($cInfo) && is_object($cInfo) && ($customers['customers_id'] == $cInfo->customers_id)) { echo tep_image(DIR_WS_IMAGES . 'icon_arrow_right.gif', ''); } else { echo '<a href="' . tep_href_link(FILENAME_CUSTOMERS, tep_get_all_get_params(array('cID')) . 'cID=' . $customers['customers_id']) . '">' . tep_image(DIR_WS_IMAGES . 'icon_info.gif', IMAGE_ICON_INFO) . '</a>'; } ?> </td>
             </tr>
<?php
   }
?>
             <tr>
               <td colspan="4"><table border="0" width="100%" cellspacing="0" cellpadding="2">
                 <tr>
                   <td class="smallText" valign="top"><?php echo $customers_split->display_count($customers_query_numrows, MAX_DISPLAY_SEARCH_RESULTS, $HTTP_GET_VARS['page'], TEXT_DISPLAY_NUMBER_OF_CUSTOMERS); ?></td>
                   <td class="smallText" align="right"><?php echo $customers_split->display_links($customers_query_numrows, MAX_DISPLAY_SEARCH_RESULTS, MAX_DISPLAY_PAGE_LINKS, $HTTP_GET_VARS['page'], tep_get_all_get_params(array('page', 'info', 'x', 'y', 'cID'))); ?></td>
                 </tr>
<?php
   if (isset($HTTP_GET_VARS['search']) && tep_not_null($HTTP_GET_VARS['search'])) {
?>
                 <tr>
                   <td class="smallText" align="right" colspan="2"><?php echo tep_draw_button(IMAGE_RESET, 'arrowrefresh-1-w', tep_href_link(FILENAME_CUSTOMERS)); ?></td>
                 </tr>
<?php
   }
?>
               </table></td>
             </tr>
           </table></td>
<?php
 $heading = array();
 $contents = array();

 switch ($action) {
   case 'confirm':
     $heading[] = array('text' => '<strong>' . TEXT_INFO_HEADING_DELETE_CUSTOMER . '</strong>');

     $contents = array('form' => tep_draw_form('customers', FILENAME_CUSTOMERS, tep_get_all_get_params(array('cID', 'action')) . 'cID=' . $cInfo->customers_id . '&action=deleteconfirm'));
     $contents[] = array('text' => TEXT_DELETE_INTRO . '<br /><br /><strong>' . $cInfo->customers_firstname . ' ' . $cInfo->customers_lastname . '</strong>');
     if (isset($cInfo->number_of_reviews) && ($cInfo->number_of_reviews) > 0) $contents[] = array('text' => '<br />' . tep_draw_checkbox_field('delete_reviews', 'on', true) . ' ' . sprintf(TEXT_DELETE_REVIEWS, $cInfo->number_of_reviews));
     $contents[] = array('align' => 'center', 'text' => '<br />' . tep_draw_button(IMAGE_DELETE, 'trash', null, 'primary') . tep_draw_button(IMAGE_CANCEL, 'close', tep_href_link(FILENAME_CUSTOMERS, tep_get_all_get_params(array('cID', 'action')) . 'cID=' . $cInfo->customers_id)));
     break;
   case 'deladdress':
     $heading[] = array('text' => '<strong>' . TEXT_DELETE_ADDRESS . '</strong>');
     if (isset($HTTP_GET_VARS['aid']) && (!in_array($address_id, array($cInfo->customers_default_address_id, $cInfo->customers_default_billing_address_id, $cInfo->customers_default_shipping_address_id)))) { // if not default address
       $contents = array('form' => tep_draw_form('customersaddress', FILENAME_CUSTOMERS, tep_get_all_get_params(array('cID', 'action','aid')) . 'cID=' . $cInfo->customers_id . '&action=confirmaddressdelete&aid=' . $address_id));
       $contents[] = array('text' => TEXT_DELETE_ADDRESS_INTRO . '<br /><br /><strong>' . $cInfo->customers_firstname . ' ' . $cInfo->customers_lastname . '</strong><br /><br />' . address_label($cInfo->customers_id, $address_id));
       $contents[] = array('align' => 'center', 'text' => '<br />' . tep_draw_button(IMAGE_DELETE, 'trash') . tep_draw_button(IMAGE_CANCEL, 'cancel', tep_href_link(FILENAME_CUSTOMERS, tep_get_all_get_params(array('cID', 'action')) . 'action=edit&cID=' . $cInfo->customers_id), 'primary'));
     } else { 
       $contents[] = array('text' => '<strong>' . TEXT_DELETE_ADDRESS_ERROR . '<strong><br />');
       $contents[] = array('align' => 'center', 'text' => tep_draw_button(IMAGE_CANCEL, 'cancel', tep_href_link(FILENAME_CUSTOMERS, tep_get_all_get_params(array('cID', 'action')) . 'action=edit&cID=' . $cInfo->customers_id), 'primary'));
     }
     break;
   default:
     if (isset($cInfo) && is_object($cInfo)) {
       $heading[] = array('text' => '<strong>' . $cInfo->customers_firstname . ' ' . $cInfo->customers_lastname . '</strong>');

       $contents[] = array('align' => 'center', 'text' => tep_draw_button(IMAGE_EDIT, 'document', tep_href_link(FILENAME_CUSTOMERS, tep_get_all_get_params(array('cID', 'action')) . 'cID=' . $cInfo->customers_id . '&action=edit')) . tep_draw_button(IMAGE_DELETE, 'trash', tep_href_link(FILENAME_CUSTOMERS, tep_get_all_get_params(array('cID', 'action')) . 'cID=' . $cInfo->customers_id . '&action=confirm')) . tep_draw_button(IMAGE_ORDERS, 'cart', tep_href_link(FILENAME_ORDERS, 'cID=' . $cInfo->customers_id)) . tep_draw_button(IMAGE_EMAIL, 'mail-closed', tep_href_link(FILENAME_MAIL, 'customer=' . $cInfo->customers_email_address)) . tep_draw_button(BUTTON_NEW_PWD, 'key', tep_href_link(FILENAME_CUSTOMERS, tep_get_all_get_params(array('cID', 'action')) . 'cID=' . $cInfo->customers_id . '&action=newpwd')));
       $contents[] = array('text' => '<br />' . TEXT_DATE_ACCOUNT_CREATED . ' ' . tep_date_short($cInfo->date_account_created));
       $contents[] = array('text' => '<br />' . TEXT_DATE_ACCOUNT_LAST_MODIFIED . ' ' . tep_date_short($cInfo->date_account_last_modified));
       $contents[] = array('text' => '<br />' . TEXT_INFO_DATE_LAST_LOGON . ' '  . tep_date_short($cInfo->date_last_logon));
       $contents[] = array('text' => '<br />' . TEXT_INFO_NUMBER_OF_LOGONS . ' ' . $cInfo->number_of_logons);
       $query = tep_db_query("select count(orders_id) as total from " . TABLE_ORDERS . " where customers_id = " . (int)$cInfo->customers_id);
       $orders = tep_db_fetch_array($query);
       $contents[] = array('text' => TEXT_INFO_NUMBER_OF_ORDERS . ' ' . $orders['total']);
       $contents[] = array('text' => '<br />' . TEXT_INFO_COUNTRY . ' ' . $cInfo->countries_name);
       $contents[] = array('text' => '<br />' . TEXT_INFO_NUMBER_OF_REVIEWS . ' ' . $cInfo->number_of_reviews);
       // FWR TAX EXEMPT
       $org_type_query = tep_db_query("select org_type_title from " . TABLE_ORGANIZATION_TYPE . " where org_type_id=" . $cInfo->customers_org_type);
       $org_type_row = tep_db_fetch_array($org_type_query);
       $contents[] = array('text' => '<br>' . TEXT_INFO_ORGANIZATION_TYPE . ' ' . $org_type_row['org_type_title']);
       // END FWR TAX EXEMPT
       $defaults = array_unique(array($cInfo->customers_default_address_id, $cInfo->customers_default_billing_address_id, $cInfo->customers_default_shipping_address_id));
       foreach ($defaults as $id) {
         $text = '<br /><em>';
         if ($id == $cInfo->customers_default_address_id) $text .= TEXT_DEFAULT . TEXT_MAILING . '<br />';
         if ($id == $cInfo->customers_default_billing_address_id) $text .= TEXT_DEFAULT . TEXT_BILLING . '<br />';
         if ($id == $cInfo->customers_default_shipping_address_id) $text .= TEXT_DEFAULT . TEXT_SHIPPING . '<br />';
         $contents[] = array('text' => $text . '</em>' . address_label($cInfo->customers_id, $id));
       }
     }
     break;
 }

 if ( (tep_not_null($heading)) && (tep_not_null($contents)) ) {
   echo '            <td width="25%" valign="top">' . "\n";

   $box = new box;
   echo $box->infoBox($heading, $contents);

   echo '            </td>' . "\n";
 }
?>
         </tr>
       </table></td>
     </tr>
<?php
 }
?>
   </table>

<?php
 require(DIR_WS_INCLUDES . 'template_bottom.php');
 require(DIR_WS_INCLUDES . 'application_bottom.php');
?>

Link to comment
Share on other sites

I think I found the problem and it appears to have to do with the Tax Exempt code.

 

After playing around with it for a while I get an error on /admin/customers.php

 

1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1

 

select org_type_title from organization_type where org_type_id=

catalog/admin/customers.php

$org_type_query = tep_db_query("select org_type_title from " . TABLE_ORGANIZATION_TYPE . " where org_type_id=" . $cInfo->customers_org_type);

 

I am thinking that is why I received the other error.

 

Here is the data I used to alter the SQL Tables

 

alter table customers add column customers_tax_exempt int(1) not null default 0;
alter table customers add column customers_tax_exempt_id char(32);
alter table customers add column customers_org_type int not null;

alter table orders add column customers_tax_exempt int(1) not null default 0;
alter table orders add column customers_tax_exempt_id char(32);
alter table orders add column customers_org_type int not null;

CREATE TABLE organization_type (
org_type_id int(11) NOT NULL auto_increment,
org_type_title varchar(32) NOT NULL default '',
org_type_description varchar(255) NOT NULL default '',
last_modified datetime default NULL,
date_added datetime NOT NULL,
org_type_discount tinyint(1) not null default 0,
PRIMARY KEY (org_type_id)
) TYPE=MyISAM;

INSERT INTO `organization_type` (`org_type_id`, `org_type_title`, `org_type_description`, `last_modified`, `date_added`, `org_type_discount`) VALUES
(0, 'None', 'Not Applicable', NULL, NOW(), 0);

Edited by qspider
Link to comment
Share on other sites

I was able to fix the 1064 SQL ERROR by placing an (int) before the $cInfo but now I'm getting the same error as before... It's supposed to return an array.

 

Warning: reset() expects parameter 1 to be array, boolean given in /public_html/admin/includes/classes/object_info.php on line 17

 

Warning: Variable passed to each() is not an array or object in /public_html/admin/includes/classes/object_info.php on line 18

Link to comment
Share on other sites

I am just removing the FWR Tax Exempt add on from this page. Not sure why it's not working but since this is the administration part I can change the values in the database myself instead of having the add on do it.

Link to comment
Share on other sites

  • 2 years later...
  • 8 months later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...