Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

adding fields to admin customer edit area


wblandt

Recommended Posts

I want to add tax id and resale license to my admin area under customers where you select the customer then edit them. I want to add the tax id and resale license under company in that area. I have it in my create_account.php that way and would like to carry it to the admin area.

 

Here is the code from my create_account.php to reference what I am doing. I can post the code from any other if needed. Thanks for the help.

 

<?php

/*

$Id$

 

osCommerce, Open Source E-Commerce Solutions

http://www.oscommerce.com

 

Copyright © 2010 osCommerce

 

Released under the GNU General Public License

*/

 

require('includes/application_top.php');

 

// needs to be included earlier to set the success message in the messageStack

require(DIR_WS_LANGUAGES . $language . '/' . FILENAME_CREATE_ACCOUNT);

 

$process = false;

if (isset($HTTP_POST_VARS['action']) && ($HTTP_POST_VARS['action'] == 'process') && isset($HTTP_POST_VARS['formid']) && ($HTTP_POST_VARS['formid'] == $sessiontoken)) {

$process = true;

 

if (ACCOUNT_GENDER == 'true') {

if (isset($HTTP_POST_VARS['gender'])) {

$gender = tep_db_prepare_input($HTTP_POST_VARS['gender']);

} else {

$gender = false;

}

}

$firstname = tep_db_prepare_input($HTTP_POST_VARS['firstname']);

$lastname = tep_db_prepare_input($HTTP_POST_VARS['lastname']);

if (ACCOUNT_DOB == 'true') $dob = tep_db_prepare_input($HTTP_POST_VARS['dob']);

$email_address = tep_db_prepare_input($HTTP_POST_VARS['email_address']);

if (ACCOUNT_COMPANY == 'true') $company = tep_db_prepare_input($HTTP_POST_VARS['company']);

$street_address = tep_db_prepare_input($HTTP_POST_VARS['street_address']);

if (ACCOUNT_SUBURB == 'true') $suburb = tep_db_prepare_input($HTTP_POST_VARS['suburb']);

$postcode = tep_db_prepare_input($HTTP_POST_VARS['postcode']);

$city = tep_db_prepare_input($HTTP_POST_VARS['city']);

 

$tax = tep_db_prepare_input($HTTP_POST_VARS['tax']);

$resale = tep_db_prepare_input($HTTP_POST_VARS['resale']);

$location = tep_db_prepare_input($HTTP_POST_VARS['location']);

if (ACCOUNT_STATE == 'true') {

$state = tep_db_prepare_input($HTTP_POST_VARS['state']);

if (isset($HTTP_POST_VARS['zone_id'])) {

$zone_id = tep_db_prepare_input($HTTP_POST_VARS['zone_id']);

} else {

$zone_id = false;

}

}

$country = tep_db_prepare_input($HTTP_POST_VARS['country']);

$telephone = tep_db_prepare_input($HTTP_POST_VARS['telephone']);

$fax = tep_db_prepare_input($HTTP_POST_VARS['fax']);

if (isset($HTTP_POST_VARS['newsletter'])) {

$newsletter = tep_db_prepare_input($HTTP_POST_VARS['newsletter']);

} else {

$newsletter = false;

}

$password = tep_db_prepare_input($HTTP_POST_VARS['password']);

$confirmation = tep_db_prepare_input($HTTP_POST_VARS['confirmation']);

 

$error = false;

 

if (ACCOUNT_GENDER == 'true') {

if ( ($gender != 'm') && ($gender != 'f') ) {

$error = true;

 

$messageStack->add('create_account', ENTRY_GENDER_ERROR);

}

}

if (entry_location == 'true') {

if ( ($location != 'Location has a dock with forklift') && ($location != 'Location has a dock without forklift

') ) {

$error = true;

 

$messageStack->add('create_account', ENTRY_LOCATION_ERROR);

}

}

 

if (strlen($firstname) < ENTRY_FIRST_NAME_MIN_LENGTH) {

$error = true;

 

$messageStack->add('create_account', ENTRY_FIRST_NAME_ERROR);

}

 

if (strlen($lastname) < ENTRY_LAST_NAME_MIN_LENGTH) {

$error = true;

 

$messageStack->add('create_account', ENTRY_LAST_NAME_ERROR);

}

 

if (ACCOUNT_DOB == 'true') {

if ((is_numeric(tep_date_raw($dob)) == false) || (@checkdate(substr(tep_date_raw($dob), 4, 2), substr(tep_date_raw($dob), 6, 2), substr(tep_date_raw($dob), 0, 4)) == false)) {

$error = true;

 

$messageStack->add('create_account', ENTRY_DATE_OF_BIRTH_ERROR);

}

}

 

if (strlen($email_address) < ENTRY_EMAIL_ADDRESS_MIN_LENGTH) {

$error = true;

 

$messageStack->add('create_account', ENTRY_EMAIL_ADDRESS_ERROR);

} elseif (tep_validate_email($email_address) == false) {

$error = true;

 

$messageStack->add('create_account', ENTRY_EMAIL_ADDRESS_CHECK_ERROR);

} else {

$check_email_query = tep_db_query("select count(*) as total from " . TABLE_CUSTOMERS . " where customers_email_address = '" . tep_db_input($email_address) . "'");

$check_email = tep_db_fetch_array($check_email_query);

if ($check_email['total'] > 0) {

$error = true;

 

$messageStack->add('create_account', ENTRY_EMAIL_ADDRESS_ERROR_EXISTS);

}

}

 

if (strlen($street_address) < ENTRY_STREET_ADDRESS_MIN_LENGTH) {

$error = true;

 

$messageStack->add('create_account', ENTRY_STREET_ADDRESS_ERROR);

}

 

if (strlen($postcode) < ENTRY_POSTCODE_MIN_LENGTH) {

$error = true;

 

$messageStack->add('create_account', ENTRY_POST_CODE_ERROR);

}

 

if (strlen($city) < ENTRY_CITY_MIN_LENGTH) {

$error = true;

 

$messageStack->add('create_account', ENTRY_CITY_ERROR);

}

 

if (is_numeric($country) == false) {

$error = true;

 

$messageStack->add('create_account', ENTRY_COUNTRY_ERROR);

}

 

if (ACCOUNT_STATE == 'true') {

$zone_id = 0;

$check_query = tep_db_query("select count(*) as total from " . TABLE_ZONES . " where zone_country_id = '" . (int)$country . "'");

$check = tep_db_fetch_array($check_query);

$entry_state_has_zones = ($check['total'] > 0);

if ($entry_state_has_zones == true) {

$zone_query = tep_db_query("select distinct zone_id from " . TABLE_ZONES . " where zone_country_id = '" . (int)$country . "' and (zone_name = '" . tep_db_input($state) . "' or zone_code = '" . tep_db_input($state) . "')");

if (tep_db_num_rows($zone_query) == 1) {

$zone = tep_db_fetch_array($zone_query);

$zone_id = $zone['zone_id'];

} else {

$error = true;

 

$messageStack->add('create_account', ENTRY_STATE_ERROR_SELECT);

}

} else {

if (strlen($state) < ENTRY_STATE_MIN_LENGTH) {

$error = true;

 

$messageStack->add('create_account', ENTRY_STATE_ERROR);

}

}

}

 

if (strlen($telephone) < ENTRY_TELEPHONE_MIN_LENGTH) {

$error = true;

 

$messageStack->add('create_account', ENTRY_TELEPHONE_NUMBER_ERROR);

}

 

if (strlen($tax) < ENTRY_NUMBER_MIN_LENGTH) {

$error = true;

 

$messageStack->add('create_account', ENTRY_NUMBER_NUMBER_ERROR);

}

 

 

if (strlen($password) < ENTRY_PASSWORD_MIN_LENGTH) {

$error = true;

 

$messageStack->add('create_account', ENTRY_PASSWORD_ERROR);

} elseif ($password != $confirmation) {

$error = true;

 

$messageStack->add('create_account', ENTRY_PASSWORD_ERROR_NOT_MATCHING);

}

 

if ($error == false) {

$sql_data_array = array('customers_firstname' => $firstname,

'customers_lastname' => $lastname,

'customers_email_address' => $email_address,

'entry_tax_number' => $tax,

'entry_resale_number' => $resale,

'entry_location' => $location,

'customers_telephone' => $telephone,

'customers_fax' => $fax,

'customers_newsletter' => $newsletter,

'customers_password' => tep_encrypt_password($password));

 

if (ACCOUNT_GENDER == 'true') $sql_data_array['customers_gender'] = $gender;

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

 

tep_db_perform(TABLE_CUSTOMERS, $sql_data_array);

 

$customer_id = tep_db_insert_id();

 

$sql_data_array = array('customers_id' => $customer_id,

'entry_firstname' => $firstname,

'entry_lastname' => $lastname,

'entry_street_address' => $street_address,

'entry_postcode' => $postcode,

'entry_city' => $city,

'entry_country_id' => $country);

 

if (ACCOUNT_GENDER == 'true') $sql_data_array['entry_gender'] = $gender;

if (ACCOUNT_COMPANY == 'true') $sql_data_array['entry_company'] = $company;

if (ACCOUNT_SUBURB == 'true') $sql_data_array['entry_address_2'] = $suburb;

if (ACCOUNT_STATE == 'true') {

if ($zone_id > 0) {

$sql_data_array['entry_zone_id'] = $zone_id;

$sql_data_array['entry_state'] = '';

} else {

$sql_data_array['entry_zone_id'] = '0';

$sql_data_array['entry_state'] = $state;

}

}

 

tep_db_perform(TABLE_ADDRESS_BOOK, $sql_data_array);

 

$address_id = tep_db_insert_id();

 

tep_db_query("update " . TABLE_CUSTOMERS . " set customers_default_address_id = '" . (int)$address_id . "' where customers_id = '" . (int)$customer_id . "'");

 

tep_db_query("insert into " . TABLE_CUSTOMERS_INFO . " (customers_info_id, customers_info_number_of_logons, customers_info_date_account_created) values ('" . (int)$customer_id . "', '0', now())");

 

if (SESSION_RECREATE == 'True') {

tep_session_recreate();

}

 

$customer_first_name = $firstname;

$customer_default_address_id = $address_id;

$customer_country_id = $country;

$customer_zone_id = $zone_id;

tep_session_register('customer_id');

tep_session_register('customer_first_name');

tep_session_register('customer_default_address_id');

tep_session_register('customer_country_id');

tep_session_register('customer_zone_id');

 

// reset session token

$sessiontoken = md5(tep_rand() . tep_rand() . tep_rand() . tep_rand());

 

// restore cart contents

$cart->restore_contents();

 

// build the message content

$name = $firstname . ' ' . $lastname;

 

if (ACCOUNT_GENDER == 'true') {

if ($gender == 'm') {

$email_text = sprintf(EMAIL_GREET_MR, $lastname);

} else {

$email_text = sprintf(EMAIL_GREET_MS, $lastname);

}

} else {

$email_text = sprintf(EMAIL_GREET_NONE, $firstname);

}

 

$email_text .= EMAIL_WELCOME . EMAIL_TEXT . EMAIL_CONTACT . EMAIL_WARNING;

tep_mail($name, $email_address, EMAIL_SUBJECT, $email_text, STORE_OWNER, STORE_OWNER_EMAIL_ADDRESS);

 

tep_redirect(tep_href_link(FILENAME_CREATE_ACCOUNT_SUCCESS, '', 'SSL'));

}

}

 

$breadcrumb->add(NAVBAR_TITLE, tep_href_link(FILENAME_CREATE_ACCOUNT, '', 'SSL'));

 

require(DIR_WS_INCLUDES . 'template_top.php');

require('includes/form_check.js.php');

?>

 

<h1><?php echo HEADING_TITLE; ?></h1>

 

<?php

if ($messageStack->size('create_account') > 0) {

echo $messageStack->output('create_account');

}

?>

 

<p><?php echo sprintf(TEXT_ORIGIN_LOGIN, tep_href_link(FILENAME_LOGIN, tep_get_all_get_params(), 'SSL')); ?></p>

 

<?php echo tep_draw_form('create_account', tep_href_link(FILENAME_CREATE_ACCOUNT, '', 'SSL'), 'post', 'onsubmit="return check_form(create_account);"', true) . tep_draw_hidden_field('action', 'process'); ?>

 

<div class="contentContainer">

<div>

<span class="inputRequirement" style="float: right;"><?php echo FORM_REQUIRED_INFORMATION; ?></span>

<h2><?php echo CATEGORY_PERSONAL; ?></h2>

</div>

 

<div class="contentText">

<table border="0" cellspacing="2" cellpadding="2" width="100%">

 

<?php

if (ACCOUNT_GENDER == 'true') {

?>

 

<tr>

<td class="fieldKey"><?php echo ENTRY_GENDER; ?></td>

<td class="fieldValue"><?php echo tep_draw_radio_field('gender', 'm') . ' ' . MALE . ' ' . tep_draw_radio_field('gender', 'f') . ' ' . FEMALE . ' ' . (tep_not_null(ENTRY_GENDER_TEXT) ? '<span class="inputRequirement">' . ENTRY_GENDER_TEXT . '</span>': ''); ?></td>

</tr>

 

<?php

}

?>

 

<tr>

<td class="fieldKey"><?php echo ENTRY_FIRST_NAME; ?></td>

<td class="fieldValue"><?php echo tep_draw_input_field('firstname') . ' ' . (tep_not_null(ENTRY_FIRST_NAME_TEXT) ? '<span class="inputRequirement">' . ENTRY_FIRST_NAME_TEXT . '</span>': ''); ?></td>

</tr>

<tr>

<td class="fieldKey"><?php echo ENTRY_LAST_NAME; ?></td>

<td class="fieldValue"><?php echo tep_draw_input_field('lastname') . ' ' . (tep_not_null(ENTRY_LAST_NAME_TEXT) ? '<span class="inputRequirement">' . ENTRY_LAST_NAME_TEXT . '</span>': ''); ?></td>

</tr>

 

<?php

if (ACCOUNT_DOB == 'true') {

?>

 

<tr>

<td class="fieldKey"><?php echo ENTRY_DATE_OF_BIRTH; ?></td>

<td class="fieldValue"><?php echo tep_draw_input_field('dob', '', 'id="dob"') . ' ' . (tep_not_null(ENTRY_DATE_OF_BIRTH_TEXT) ? '<span class="inputRequirement">' . ENTRY_DATE_OF_BIRTH_TEXT . '</span>': ''); ?><script type="text/javascript">$('#dob').datepicker({dateFormat: '<?php echo JQUERY_DATEPICKER_FORMAT; ?>', changeMonth: true, changeYear: true, yearRange: '-100:+0'});</script></td>

</tr>

 

<?php

}

?>

 

<tr>

<td class="fieldKey"><?php echo ENTRY_EMAIL_ADDRESS; ?></td>

<td class="fieldValue"><?php echo tep_draw_input_field('email_address') . ' ' . (tep_not_null(ENTRY_EMAIL_ADDRESS_TEXT) ? '<span class="inputRequirement">' . ENTRY_EMAIL_ADDRESS_TEXT . '</span>': ''); ?></td>

</tr>

 

</table>

</div>

 

<?php

if (ACCOUNT_COMPANY == 'true') {

?>

 

<h2><?php echo CATEGORY_COMPANY; ?></h2>

 

<div class="contentText">

<table border="0" cellspacing="2" cellpadding="2" width="100%">

<tr>

<td class="fieldKey"><?php echo ENTRY_COMPANY; ?></td>

<td class="fieldValue"><?php echo tep_draw_input_field('company') . ' ' . (tep_not_null(ENTRY_COMPANY_TEXT) ? '<span class="inputRequirement">' . ENTRY_COMPANY_TEXT . '</span>': ''); ?></td>

</tr>

<tr>

<td class="fieldKey"><?php echo ENTRY_TAX_NUMBER; ?></td>

<td class="fieldValue"><?php echo tep_draw_input_field('tax') . ' ' . (tep_not_null(ENTRY_TAX_NUMBER_TEXT) ? '<span class="inputRequirement">' . ENTRY_TAX_NUMBER_TEXT . '</span>': ''); ?></td>

</tr>

<tr>

<td class="fieldKey"><?php echo ENTRY_TAX_RESALE; ?></td>

<td class="fieldValue"><?php echo tep_draw_input_field('resale').' '.(tep_not_null(ENTRY_TAX_RESALE_TEXT) ? '<span class="inputRequirement">' . ENTRY_TAX_RESALE_TEXT . '</span>': ''); ?></td>

</tr>

</table>

</div>

 

<?php

}

?>

 

<h2><?php echo CATEGORY_ADDRESS; ?></h2>

 

<div class="contentText">

<table border="0" cellspacing="2" cellpadding="2" width="100%">

<tr>

<td class="fieldKey"><?php echo ENTRY_STREET_ADDRESS; ?></td>

<td class="fieldValue"><?php echo tep_draw_input_field('street_address') . ' ' . (tep_not_null(ENTRY_STREET_ADDRESS_TEXT) ? '<span class="inputRequirement">' . ENTRY_STREET_ADDRESS_TEXT . '</span>': ''); ?></td>

</tr>

 

<?php

if (ACCOUNT_SUBURB == 'true') {

?>

 

<tr>

<td class="fieldKey"><?php echo ENTRY_SUBURB; ?></td>

<td class="fieldValue"><?php echo tep_draw_input_field('suburb') . ' ' . (tep_not_null(ENTRY_SUBURB_TEXT) ? '<span class="inputRequirement">' . ENTRY_SUBURB_TEXT . '</span>': ''); ?></td>

</tr>

 

<?php

}

?>

 

<tr>

<td class="fieldKey"><?php echo ENTRY_POST_CODE; ?></td>

<td class="fieldValue"><?php echo tep_draw_input_field('postcode') . ' ' . (tep_not_null(ENTRY_POST_CODE_TEXT) ? '<span class="inputRequirement">' . ENTRY_POST_CODE_TEXT . '</span>': ''); ?></td>

</tr>

<tr>

<td class="fieldKey"><?php echo ENTRY_CITY; ?></td>

<td class="fieldValue"><?php echo tep_draw_input_field('city') . ' ' . (tep_not_null(ENTRY_CITY_TEXT) ? '<span class="inputRequirement">' . ENTRY_CITY_TEXT . '</span>': ''); ?></td>

</tr>

 

<?php

if (ACCOUNT_STATE == 'true') {

?>

 

<tr>

<td class="fieldKey"><?php echo ENTRY_STATE; ?></td>

<td class="fieldValue">

<?php

if ($process == true) {

if ($entry_state_has_zones == true) {

$zones_array = array();

$zones_query = tep_db_query("select zone_name from " . TABLE_ZONES . " where zone_country_id = '" . (int)$country . "' order by zone_name");

while ($zones_values = tep_db_fetch_array($zones_query)) {

$zones_array[] = array('id' => $zones_values['zone_name'], 'text' => $zones_values['zone_name']);

}

echo tep_draw_pull_down_menu('state', $zones_array);

} else {

echo tep_draw_input_field('state');

}

} else {

echo tep_draw_input_field('state');

}

 

if (tep_not_null(ENTRY_STATE_TEXT)) echo ' <span class="inputRequirement">' . ENTRY_STATE_TEXT . '</span>';

?>

</td>

</tr>

 

<?php

}

?>

 

<tr>

<td class="fieldKey"><?php echo ENTRY_COUNTRY; ?></td>

<td class="fieldValue"><?php echo tep_get_country_list('country') . ' ' . (tep_not_null(ENTRY_COUNTRY_TEXT) ? '<span class="inputRequirement">' . ENTRY_COUNTRY_TEXT . '</span>': ''); ?></td>

</tr>

<tr><td> </td></tr>

<tr>

<td class="fieldKey"><?php echo ENTRY_LOCATION; ?></td>

<td class="fieldValue"><?php echo tep_draw_radio_field('location','Location has a dock with forklift

') . ' ' . LOCATION_FORLIFT . '<br/>' . tep_draw_radio_field('location','Location has a dock without forklift') . '' . LOCATION_WITHOUT_FORLIFT . '<BR/>'. tep_draw_radio_field('location','Location doesn\'t have a dock') . '' . LOCATION_WITHOUT_DOESNOT . ' ' . (tep_not_null(ENTRY_GENDER_TEXT) ? '<span class="inputRequirement">' . ENTRY_GENDER_TEXT . '</span>':''); ?></td>

</tr>

</table>

</div>

 

<h2><?php echo CATEGORY_CONTACT; ?></h2>

 

<div class="contentText">

<table border="0" cellspacing="2" cellpadding="2" width="100%">

<tr>

<td class="fieldKey"><?php echo ENTRY_TELEPHONE_NUMBER; ?></td>

<td class="fieldValue"><?php echo tep_draw_input_field('telephone') . ' ' . (tep_not_null(ENTRY_TELEPHONE_NUMBER_TEXT) ? '<span class="inputRequirement">' . ENTRY_TELEPHONE_NUMBER_TEXT . '</span>': ''); ?></td>

</tr>

<tr>

<td class="fieldKey"><?php echo ENTRY_FAX_NUMBER; ?></td>

<td class="fieldValue"><?php echo tep_draw_input_field('fax') . ' ' . (tep_not_null(ENTRY_FAX_NUMBER_TEXT) ? '<span class="inputRequirement">' . ENTRY_FAX_NUMBER_TEXT . '</span>': ''); ?></td>

</tr>

<tr>

<td class="fieldKey"><?php echo ENTRY_NEWSLETTER; ?></td>

<td class="fieldValue"><?php echo tep_draw_checkbox_field('newsletter', '1') . ' ' . (tep_not_null(ENTRY_NEWSLETTER_TEXT) ? '<span class="inputRequirement">' . ENTRY_NEWSLETTER_TEXT . '</span>': ''); ?></td>

</tr>

 

</table>

</div>

 

<h2><?php echo CATEGORY_PASSWORD; ?></h2>

 

<div class="contentText">

<table border="0" cellspacing="2" cellpadding="2" width="100%">

<tr>

<td class="fieldKey"><?php echo ENTRY_PASSWORD; ?></td>

<td class="fieldValue"><?php echo tep_draw_password_field('password') . ' ' . (tep_not_null(ENTRY_PASSWORD_TEXT) ? '<span class="inputRequirement">' . ENTRY_PASSWORD_TEXT . '</span>': ''); ?></td>

</tr>

<tr>

<td class="fieldKey"><?php echo ENTRY_PASSWORD_CONFIRMATION; ?></td>

<td class="fieldValue"><?php echo tep_draw_password_field('confirmation') . ' ' . (tep_not_null(ENTRY_PASSWORD_CONFIRMATION_TEXT) ? '<span class="inputRequirement">' . ENTRY_PASSWORD_CONFIRMATION_TEXT . '</span>': ''); ?></td>

</tr>

</table>

</div>

 

<div class="buttonSet">

<span class="buttonAction"><?php echo tep_draw_button(IMAGE_BUTTON_CONTINUE, 'person', null, 'primary'); ?></span>

</div>

</div>

 

</form>

 

<?php

require(DIR_WS_INCLUDES . 'template_bottom.php');

require(DIR_WS_INCLUDES . 'application_bottom.php');

?>

Link to comment
Share on other sites

I get this error 1054 - Unknown column 'a.entry_tax' in 'field list'

 

select c.customers_id, c.customers_gender, c.customers_firstname, c.customers_lastname, c.customers_dob, c.customers_email_address, a.entry_company, a.entry_tax, a.entry_resale, 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 customers c left join address_book a on c.customers_default_address_id = a.address_book_id where a.customers_id = c.customers_id and c.customers_id = '12'

 

[TEP STOP]

 

when I try to add tax and resale to the customers.php file in admin.

 

here is the code of the customer.php file:

 

<?php

/*

$Id$

 

osCommerce, Open Source E-Commerce Solutions

http://www.oscommerce.com

 

Copyright © 2010 osCommerce

 

Released under the GNU General Public License

*/

 

require('includes/application_top.php');

 

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

 

$error = false;

$processed = false;

 

if (tep_not_null($action)) {

switch ($action) {

case 'update':

$customers_id = tep_db_prepare_input($HTTP_GET_VARS['cID']);

$customers_firstname = tep_db_prepare_input($HTTP_POST_VARS['customers_firstname']);

$customers_lastname = tep_db_prepare_input($HTTP_POST_VARS['customers_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_fax = tep_db_prepare_input($HTTP_POST_VARS['customers_fax']);

$customers_newsletter = tep_db_prepare_input($HTTP_POST_VARS['customers_newsletter']);

 

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

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

 

$default_address_id = tep_db_prepare_input($HTTP_POST_VARS['default_address_id']);

$entry_street_address = tep_db_prepare_input($HTTP_POST_VARS['entry_street_address']);

$entry_suburb = tep_db_prepare_input($HTTP_POST_VARS['entry_suburb']);

$entry_postcode = 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']);

$entry_tax = tep_db_prepare_input($HTTP_POST_VARS['entry_tax']);

$entry_resale = tep_db_prepare_input($HTTP_POST_VARS['entry_resale']);

$entry_state = tep_db_prepare_input($HTTP_POST_VARS['entry_state']);

if (isset($HTTP_POST_VARS['entry_zone_id'])) $entry_zone_id = tep_db_prepare_input($HTTP_POST_VARS['entry_zone_id']);

 

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 (ACCOUNT_DOB == 'true') {

if (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))) {

$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_postcode) < ENTRY_POSTCODE_MIN_LENGTH) {

$error = true;

$entry_post_code_error = true;

} else {

$entry_post_code_error = false;

}

 

if (strlen($entry_city) < ENTRY_CITY_MIN_LENGTH) {

$error = true;

$entry_city_error = true;

} else {

$entry_city_error = false;

}

 

if ($entry_country_id == false) {

$error = true;

$entry_country_error = true;

} else {

$entry_country_error = false;

}

 

if (ACCOUNT_STATE == 'true') {

if ($entry_country_error == true) {

$entry_state_error = true;

} else {

$zone_id = 0;

$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_id from " . TABLE_ZONES . " where zone_country_id = '" . (int)$entry_country_id . "' and zone_name = '" . tep_db_input($entry_state) . "'");

if (tep_db_num_rows($zone_query) == 1) {

$zone_values = tep_db_fetch_array($zone_query);

$entry_zone_id = $zone_values['zone_id'];

} else {

$error = true;

$entry_state_error = true;

}

} else {

if (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 = true;

} else {

$entry_telephone_error = false;

}

 

$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_fax' => $customers_fax,

'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_zone_id > 0) $entry_state = '';

 

$sql_data_array = array('entry_firstname' => $customers_firstname,

'entry_lastname' => $customers_lastname,

'entry_street_address' => $entry_street_address,

'entry_postcode' => $entry_postcode,

'entry_city' => $entry_city,

'entry_country_id' => $entry_country_id);

 

if (ACCOUNT_COMPANY == 'true') $sql_data_array['entry_company'] = $entry_company;

if (ACCOUNT_TAX == 'true') $sql_data_array['entry_tax'] = $entry_company;

if (ACCOUNT_RESALE == 'true') $sql_data_array['entry_resale'] = $entry_company;

if (ACCOUNT_SUBURB == 'true') $sql_data_array['entry_suburb'] = $entry_suburb;

 

if (ACCOUNT_STATE == 'true') {

if ($entry_zone_id > 0) {

$sql_data_array['entry_zone_id'] = $entry_zone_id;

$sql_data_array['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)$default_address_id . "'");

 

tep_redirect(tep_href_link(FILENAME_CUSTOMERS, tep_get_all_get_params(array('cID', 'action')) . '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 . "'");

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_company, a.entry_tax, a.entry_resale, 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 = '" . (int)$HTTP_GET_VARS['cID'] . "'");

$customers = tep_db_fetch_array($customers_query);

$cInfo = new objectInfo($customers);

}

}

 

require(DIR_WS_INCLUDES . 'template_top.php');

 

if ($action == 'edit' || $action == 'update') {

?>

<script type="text/javascript"><!--

 

function check_form() {

var error = 0;

var error_message = "<?php echo JS_ERROR; ?>";

 

var customers_firstname = document.customers.customers_firstname.value;

var customers_lastname = document.customers.customers_lastname.value;

<?php if (ACCOUNT_COMPANY == 'true') echo 'var entry_company = document.customers.entry_company.value;' . "\n"; ?>

<?php if (ACCOUNT_TAX == 'true') echo 'var entry_tax = document.customers.entry_tax.value;' . "\n"; ?>

<?php if (ACCOUNT_RESALE == 'true') echo 'var entry_resale = document.customers.entry_resale.value;' . "\n"; ?>

<?php if (ACCOUNT_DOB == 'true') echo 'var customers_dob = document.customers.customers_dob.value;' . "\n"; ?>

var customers_email_address = document.customers.customers_email_address.value;

var entry_street_address = document.customers.entry_street_address.value;

var entry_postcode = document.customers.entry_postcode.value;

var entry_city = document.customers.entry_city.value;

var customers_telephone = document.customers.customers_telephone.value;

 

<?php if (ACCOUNT_GENDER == 'true') { ?>

if (document.customers.customers_gender[0].checked || document.customers.customers_gender[1].checked) {

} else {

error_message = error_message + "<?php echo JS_GENDER; ?>";

error = 1;

}

<?php } ?>

 

if (customers_firstname.length < <?php echo ENTRY_FIRST_NAME_MIN_LENGTH; ?>) {

error_message = error_message + "<?php echo JS_FIRST_NAME; ?>";

error = 1;

}

 

if (customers_lastname.length < <?php echo ENTRY_LAST_NAME_MIN_LENGTH; ?>) {

error_message = error_message + "<?php echo JS_LAST_NAME; ?>";

error = 1;

}

 

<?php if (ACCOUNT_DOB == 'true') { ?>

if (customers_dob.length < <?php echo ENTRY_DOB_MIN_LENGTH; ?>) {

error_message = error_message + "<?php echo JS_DOB; ?>";

error = 1;

}

<?php } ?>

 

if (customers_email_address.length < <?php echo ENTRY_EMAIL_ADDRESS_MIN_LENGTH; ?>) {

error_message = error_message + "<?php echo JS_EMAIL_ADDRESS; ?>";

error = 1;

}

 

if (entry_street_address.length < <?php echo ENTRY_STREET_ADDRESS_MIN_LENGTH; ?>) {

error_message = error_message + "<?php echo JS_ADDRESS; ?>";

error = 1;

}

 

if (entry_postcode.length < <?php echo ENTRY_POSTCODE_MIN_LENGTH; ?>) {

error_message = error_message + "<?php echo JS_POST_CODE; ?>";

error = 1;

}

 

if (entry_city.length < <?php echo ENTRY_CITY_MIN_LENGTH; ?>) {

error_message = error_message + "<?php echo JS_CITY; ?>";

error = 1;

}

 

<?php

if (ACCOUNT_STATE == 'true') {

?>

if (document.customers.elements['entry_state'].type != "hidden") {

if (document.customers.entry_state.value.length < <?php echo ENTRY_STATE_MIN_LENGTH; ?>) {

error_message = error_message + "<?php echo JS_STATE; ?>";

error = 1;

}

}

<?php

}

?>

 

if (document.customers.elements['entry_country_id'].type != "hidden") {

if (document.customers.entry_country_id.value == 0) {

error_message = error_message + "<?php echo JS_COUNTRY; ?>";

error = 1;

}

}

 

if (customers_telephone.length < <?php echo ENTRY_TELEPHONE_MIN_LENGTH; ?>) {

error_message = error_message + "<?php echo JS_TELEPHONE; ?>";

error = 1;

}

 

if (error == 1) {

alert(error_message);

return false;

} else {

return true;

}

}

//--></script>

<?php

}

?>

 

<table border="0" width="100%" cellspacing="0" cellpadding="2">

<?php

if ($action == 'edit' || $action == 'update') {

$newsletter_array = array(array('id' => '1', 'text' => ENTRY_NEWSLETTER_YES),

array('id' => '0', 'text' => ENTRY_NEWSLETTER_NO));

?>

<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><?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')) . 'action=update', 'post', 'onsubmit="return check_form();"') . tep_draw_hidden_field('default_address_id', $cInfo->customers_default_address_id); ?>

<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, 'maxlength="32"') . ' ' . 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, 'maxlength="32"', 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, 'maxlength="32"') . ' ' . 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, 'maxlength="32"', 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), 'maxlength="10"') . ' ' . 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), 'maxlength="10" 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, 'maxlength="96"') . ' ' . ENTRY_EMAIL_ADDRESS_ERROR;

} elseif ($entry_email_address_check_error == true) {

echo tep_draw_input_field('customers_email_address', $cInfo->customers_email_address, 'maxlength="96"') . ' ' . ENTRY_EMAIL_ADDRESS_CHECK_ERROR;

} elseif ($entry_email_address_exists == true) {

echo tep_draw_input_field('customers_email_address', $cInfo->customers_email_address, 'maxlength="96"') . ' ' . 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, 'maxlength="96"', true);

}

?></td>

</tr>

</table></td>

</tr>

<?php

if (ACCOUNT_COMPANY == 'true') {

?>

<tr>

<td><?php echo tep_draw_separator('pixel_trans.gif', '1', '10'); ?></td>

</tr>

<tr>

<td class="formAreaTitle"><?php echo CATEGORY_COMPANY; ?></td>

</tr>

<tr>

<td class="formArea"><table border="0" cellspacing="2" cellpadding="2">

<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, 'maxlength="32"');

}

?></td>

<tr>

<td class="formAreaTitle"><?php echo CATEGORY_TAX; ?></td>

</tr>

<tr>

<td class="formArea"><table border="0" cellspacing="2" cellpadding="2">

<tr>

<td class="main"><?php echo ENTRY_TAX; ?></td>

<td class="main">

<?php

if ($error == true) {

echo $cInfo->entry_tax . tep_draw_hidden_field('entry_tax');

} else {

echo tep_draw_input_field('entry_tax', $cInfo->entry_tax, 'maxlength="32"');

}

?></td>

<tr>

<td class="formAreaTitle"><?php echo CATEGORY_RESALE; ?></td>

</tr>

<tr>

<td class="formArea"><table border="0" cellspacing="2" cellpadding="2">

<tr>

<td class="main"><?php echo ENTRY_RESALE; ?></td>

<td class="main">

<?php

if ($error == true) {

echo $cInfo->entry_resale . tep_draw_hidden_field('entry_resale');

} else {

echo tep_draw_input_field('entry_resale', $cInfo->entry_resale, 'maxlength="32"');

}

?></td>

</tr>

</table></td>

</tr>

<?php

}

?>

<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_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, 'maxlength="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, 'maxlength="64"', true);

}

?></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, 'maxlength="32"');

}

?></td>

</tr>

<?php

}

?>

<tr>

<td class="main"><?php echo ENTRY_POST_CODE; ?></td>

<td class="main">

<?php

if ($error == true) {

if ($entry_post_code_error == true) {

echo tep_draw_input_field('entry_postcode', $cInfo->entry_postcode, 'maxlength="8"') . ' ' . 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, 'maxlength="8"', true);

}

?></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, 'maxlength="32"') . ' ' . 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, 'maxlength="32"', 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 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_name'], 'text' => $zones_values['zone_name']);

}

echo tep_draw_pull_down_menu('entry_state', $zones_array) . ' ' . ENTRY_STATE_ERROR;

} else {

echo tep_draw_input_field('entry_state', tep_get_zone_name($cInfo->entry_country_id, $cInfo->entry_zone_id, $cInfo->entry_state)) . ' ' . ENTRY_STATE_ERROR;

}

} else {

echo $entry_state . tep_draw_hidden_field('entry_zone_id') . tep_draw_hidden_field('entry_state');

}

} else {

echo tep_draw_input_field('entry_state', tep_get_zone_name($cInfo->entry_country_id, $cInfo->entry_zone_id, $cInfo->entry_state));

}

 

?></td>

</tr>

<?php

}

?>

<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', tep_get_countries(), $cInfo->entry_country_id) . ' ' . 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', tep_get_countries(), $cInfo->entry_country_id);

}

?></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 == true) {

echo tep_draw_input_field('customers_telephone', $cInfo->customers_telephone, 'maxlength="32"') . ' ' . ENTRY_TELEPHONE_NUMBER_ERROR;

} else {

echo $cInfo->customers_telephone . tep_draw_hidden_field('customers_telephone');

}

} else {

echo tep_draw_input_field('customers_telephone', $cInfo->customers_telephone, 'maxlength="32"', true);

}

?></td>

</tr>

<tr>

<td class="main"><?php echo ENTRY_FAX_NUMBER; ?></td>

<td class="main">

<?php

if ($processed == true) {

echo $cInfo->customers_fax . tep_draw_hidden_field('customers_fax');

} else {

echo tep_draw_input_field('customers_fax', $cInfo->customers_fax, 'maxlength="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')))); ?></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>

<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 . "%'";

}

$customers_query_raw = "select c.customers_id, c.customers_lastname, c.customers_firstname, 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";

$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);

 

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>

<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;

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)));

$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);

$contents[] = array('text' => '<br />' . TEXT_INFO_COUNTRY . ' ' . $cInfo->countries_name);

$contents[] = array('text' => '<br />' . TEXT_INFO_NUMBER_OF_REVIEWS . ' ' . $cInfo->number_of_reviews);

}

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

  • 3 months later...
a.entry_tax

 

You need to create the field in the customers table to hold the data being entered into the form. Subsequently, you call the information into the customers.php file to display it in the admin area when you view the customers account.

 

 

 

Chris

Link to comment
Share on other sites

The easy way to do this is to

 

Add the field to the cutomer table using phpmy admin

 

Then edit /admin/customer.php.

Find a filed that is not validated such as fax number and where ever there is a reference to this field repeat the coding and rename it to your new filed name.

 

Also in and sql commands add the new field name if the fax field is refferred to.

 

HTH

 

G

Need help installing add ons/contributions, cleaning a hacked site or a bespoke development, check my profile

 

Virus Threat Scanner

My Contributions

Basic install answers.

Click here for Contributions / Add Ons.

UK your site.

Site Move.

Basic design info.

 

For links mentioned in old answers that are no longer here follow this link Useful Threads.

 

If this post was useful, click the Like This button over there ======>>>>>.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...