[phpBB Debug] PHP Warning: in file [ROOT]/includes/crs/crs_misc_functions.php on line 37: mime_content_type(): Empty filename or path
[phpBB Debug] PHP Warning: in file [ROOT]/includes/crs/crs_misc_functions.php on line 37: mime_content_type(): Empty filename or path
Zen Cart 源代码 customers.php

Zen Cart 源代码 customers.php




下载文件

文件名: customers.php
文件类型: PHP文件
文件大小: 64.88 KiB
MD5: 4705007ab5fe166d7583b93fe68c5aff

customers.php - 关闭高亮
  1. <?php
  2. /**
  3.  * @package admin
  4.  * @copyright Copyright 2003-2012 Zen Cart Development Team
  5.  * @copyright Portions Copyright 2003 osCommerce
  6.  * @license http://www.zen-cart.com/license/2_0.txt GNU Public License V2.0
  7.  * @version GIT: $Id: Author: Ian Wilson  Tue Aug 7 15:17:58 2012 +0100 Modified in v1.5.1 $
  8.  */
  9.  
  10.   require('includes/application_top.php');
  11.  
  12.   require(DIR_WS_CLASSES . 'currencies.php');
  13.   $currencies = new currencies();
  14.  
  15.   $action = (isset($_GET['action']) ? $_GET['action'] : '');
  16.   $customers_id = zen_db_prepare_input($_GET['cID']);
  17.   if (isset($_POST['cID'])) $customers_id = zen_db_prepare_input($_POST['cID']);
  18.  
  19.   $error = false;
  20.   $processed = false;
  21.  
  22.   if (zen_not_null($action)) {
  23.     switch ($action) {
  24.       case 'list_addresses':
  25.         $addresses_query = "SELECT address_book_id, entry_firstname as firstname, entry_lastname as lastname,
  26.                            entry_company as company, entry_street_address as street_address,
  27.                            entry_suburb as suburb, entry_city as city, entry_postcode as postcode,
  28.                            entry_state as state, entry_zone_id as zone_id, entry_country_id as country_id
  29.                    FROM   " . TABLE_ADDRESS_BOOK . "
  30.                    WHERE  customers_id = :customersID
  31.                    ORDER BY firstname, lastname";
  32.  
  33.         $addresses_query = $db->bindVars($addresses_query, ':customersID', $_GET['cID'], 'integer');
  34.         $addresses = $db->Execute($addresses_query);
  35.         $addressArray = array();
  36.         while (!$addresses->EOF) {
  37.           $format_id = zen_get_address_format_id($addresses->fields['country_id']);
  38.  
  39.           $addressArray[] = array('firstname'=>$addresses->fields['firstname'],
  40.                                   'lastname'=>$addresses->fields['lastname'],
  41.                                   'address_book_id'=>$addresses->fields['address_book_id'],
  42.                                   'format_id'=>$format_id,
  43.                                   'address'=>$addresses->fields);
  44.           $addresses->MoveNext();
  45.         }
  46. ?>
  47. <fieldset>
  48. <legend><?php echo ADDRESS_BOOK_TITLE; ?></legend>
  49. <div class="alert forward"><?php echo sprintf(TEXT_MAXIMUM_ENTRIES, MAX_ADDRESS_BOOK_ENTRIES); ?></div>
  50. <br class="clearBoth" />
  51. <?php
  52. /**
  53.  * Used to loop thru and display address book entries
  54.  */
  55.   foreach ($addressArray as $addresses) {
  56. ?>
  57. <h3 class="addressBookDefaultName"><?php echo zen_output_string_protected($addresses['firstname'] . ' ' . $addresses['lastname']); ?><?php if ($addresses['address_book_id'] == zen_get_customers_address_primary($_GET['cID'])) echo '&nbsp;' . PRIMARY_ADDRESS ; ?></h3>
  58. <address><?php echo zen_address_format($addresses['format_id'], $addresses['address'], true, ' ', '<br />'); ?></address>
  59.  
  60. <br class="clearBoth" />
  61. <?php } // end list ?>
  62. <div class="buttonRow forward"><?php echo '<a href="' . zen_href_link(FILENAME_CUSTOMERS, 'action=list_addresses_done' . '&cID=' . $_GET['cID'] . ($_GET['page'] > 0 ? '&page=' . $_GET['page'] : ''), 'NONSSL') . '">' . zen_image_button('button_cancel.gif', IMAGE_CANCEL) . '</a>'; ?>
  63. </fieldset>
  64. <?php
  65.         die();
  66.         break;
  67.       case 'list_addresses_done':
  68.         $action = '';
  69.         zen_redirect(zen_href_link(FILENAME_CUSTOMERS, 'cID=' . (int)$_GET['cID'] . '&page=' . $_GET['page'], 'NONSSL'));
  70.         break;
  71.       case 'status':
  72.         if (isset($_POST['current']) && is_numeric($_POST['current']))
  73.         {
  74.           if ($_POST['current'] == CUSTOMERS_APPROVAL_AUTHORIZATION) {
  75.             $sql = "update " . TABLE_CUSTOMERS . " set customers_authorization=0 where customers_id='" . (int)$customers_id . "'";
  76.             $custinfo = $db->Execute("select customers_email_address, customers_firstname, customers_lastname
  77.                                      from " . TABLE_CUSTOMERS . "
  78.                                      where customers_id = '" . (int)$customers_id . "'");
  79.             if ((int)CUSTOMERS_APPROVAL_AUTHORIZATION > 0 && (int)$_POST['current'] > 0 && $custinfo->RecordCount() > 0) {
  80.               $message = EMAIL_CUSTOMER_STATUS_CHANGE_MESSAGE;
  81.               $html_msg['EMAIL_MESSAGE_HTML'] = EMAIL_CUSTOMER_STATUS_CHANGE_MESSAGE ;
  82.               zen_mail($custinfo->fields['customers_firstname'] . ' ' . $custinfo->fields['customers_lastname'], $custinfo->fields['customers_email_address'], EMAIL_CUSTOMER_STATUS_CHANGE_SUBJECT , $message, STORE_NAME, EMAIL_FROM, $html_msg, 'default');
  83.             }
  84.           } else {
  85.             $sql = "update " . TABLE_CUSTOMERS . " set customers_authorization='" . CUSTOMERS_APPROVAL_AUTHORIZATION . "' where customers_id='" . (int)$customers_id . "'";
  86.           }
  87.           $db->Execute($sql);
  88.           $action = '';
  89.           zen_redirect(zen_href_link(FILENAME_CUSTOMERS, 'cID=' . (int)$customers_id . '&page=' . $_GET['page'], 'NONSSL'));
  90.         }
  91.         $action = '';
  92.         break;
  93.       case 'update':
  94.         $customers_firstname = zen_db_prepare_input(zen_sanitize_string($_POST['customers_firstname']));
  95.         $customers_lastname = zen_db_prepare_input(zen_sanitize_string($_POST['customers_lastname']));
  96.         $customers_email_address = zen_db_prepare_input($_POST['customers_email_address']);
  97.         $customers_telephone = zen_db_prepare_input($_POST['customers_telephone']);
  98.         $customers_fax = zen_db_prepare_input($_POST['customers_fax']);
  99.         $customers_newsletter = zen_db_prepare_input($_POST['customers_newsletter']);
  100.         $customers_group_pricing = (int)zen_db_prepare_input($_POST['customers_group_pricing']);
  101.         $customers_email_format = zen_db_prepare_input($_POST['customers_email_format']);
  102.         $customers_gender = zen_db_prepare_input($_POST['customers_gender']);
  103.         $customers_dob = (empty($_POST['customers_dob']) ? zen_db_prepare_input('0001-01-01 00:00:00') : zen_db_prepare_input($_POST['customers_dob']));
  104.  
  105.         $customers_authorization = zen_db_prepare_input($_POST['customers_authorization']);
  106.         $customers_referral= zen_db_prepare_input($_POST['customers_referral']);
  107.  
  108.         if (CUSTOMERS_APPROVAL_AUTHORIZATION == 2 and $customers_authorization == 1) {
  109.           $customers_authorization = 2;
  110.           $messageStack->add_session(ERROR_CUSTOMER_APPROVAL_CORRECTION2, 'caution');
  111.         }
  112.  
  113.         if (CUSTOMERS_APPROVAL_AUTHORIZATION == 1 and $customers_authorization == 2) {
  114.           $customers_authorization = 1;
  115.           $messageStack->add_session(ERROR_CUSTOMER_APPROVAL_CORRECTION1, 'caution');
  116.         }
  117.  
  118.         $default_address_id = zen_db_prepare_input($_POST['default_address_id']);
  119.         $entry_street_address = zen_db_prepare_input($_POST['entry_street_address']);
  120.         $entry_suburb = zen_db_prepare_input($_POST['entry_suburb']);
  121.         $entry_postcode = zen_db_prepare_input($_POST['entry_postcode']);
  122.         $entry_city = zen_db_prepare_input($_POST['entry_city']);
  123.         $entry_country_id = zen_db_prepare_input($_POST['entry_country_id']);
  124.  
  125.         $entry_company = zen_db_prepare_input($_POST['entry_company']);
  126.         $entry_state = zen_db_prepare_input($_POST['entry_state']);
  127.         if (isset($_POST['entry_zone_id'])) $entry_zone_id = zen_db_prepare_input($_POST['entry_zone_id']);
  128.  
  129.         if (strlen($customers_firstname) < ENTRY_FIRST_NAME_MIN_LENGTH) {
  130.           $error = true;
  131.           $entry_firstname_error = true;
  132.         } else {
  133.           $entry_firstname_error = false;
  134.         }
  135.  
  136.         if (strlen($customers_lastname) < ENTRY_LAST_NAME_MIN_LENGTH) {
  137.           $error = true;
  138.           $entry_lastname_error = true;
  139.         } else {
  140.           $entry_lastname_error = false;
  141.         }
  142.  
  143.         if (ACCOUNT_DOB == 'true') {
  144.           if (ENTRY_DOB_MIN_LENGTH >0) {
  145.             if (checkdate(substr(zen_date_raw($customers_dob), 4, 2), substr(zen_date_raw($customers_dob), 6, 2), substr(zen_date_raw($customers_dob), 0, 4))) {
  146.               $entry_date_of_birth_error = false;
  147.             } else {
  148.               $error = true;
  149.               $entry_date_of_birth_error = true;
  150.             }
  151.           }
  152.         } else {
  153.             $customers_dob = '0001-01-01 00:00:00';
  154.         }
  155.  
  156.         if (strlen($customers_email_address) < ENTRY_EMAIL_ADDRESS_MIN_LENGTH) {
  157.           $error = true;
  158.           $entry_email_address_error = true;
  159.         } else {
  160.           $entry_email_address_error = false;
  161.         }
  162.  
  163.         if (!zen_validate_email($customers_email_address)) {
  164.           $error = true;
  165.           $entry_email_address_check_error = true;
  166.         } else {
  167.           $entry_email_address_check_error = false;
  168.         }
  169.  
  170.         if (strlen($entry_street_address) < ENTRY_STREET_ADDRESS_MIN_LENGTH) {
  171.           $error = true;
  172.           $entry_street_address_error = true;
  173.         } else {
  174.           $entry_street_address_error = false;
  175.         }
  176.  
  177.         if (strlen($entry_postcode) < ENTRY_POSTCODE_MIN_LENGTH) {
  178.           $error = true;
  179.           $entry_post_code_error = true;
  180.         } else {
  181.           $entry_post_code_error = false;
  182.         }
  183.  
  184.         if (strlen($entry_city) < ENTRY_CITY_MIN_LENGTH) {
  185.           $error = true;
  186.           $entry_city_error = true;
  187.         } else {
  188.           $entry_city_error = false;
  189.         }
  190.  
  191.         if ($entry_country_id == false) {
  192.           $error = true;
  193.           $entry_country_error = true;
  194.         } else {
  195.           $entry_country_error = false;
  196.         }
  197.  
  198.         if (ACCOUNT_STATE == 'true') {
  199.           if ($entry_country_error == true) {
  200.             $entry_state_error = true;
  201.           } else {
  202.             $zone_id = 0;
  203.             $entry_state_error = false;
  204.             $check_value = $db->Execute("select count(*) as total
  205.                                         from " . TABLE_ZONES . "
  206.                                         where zone_country_id = '" . (int)$entry_country_id . "'");
  207.  
  208.             $entry_state_has_zones = ($check_value->fields['total'] > 0);
  209.             if ($entry_state_has_zones == true) {
  210.               $zone_query = $db->Execute("select zone_id
  211.                                          from " . TABLE_ZONES . "
  212.                                          where zone_country_id = '" . (int)$entry_country_id . "'
  213.                                          and zone_name = '" . zen_db_input($entry_state) . "'");
  214.  
  215.               if ($zone_query->RecordCount() > 0) {
  216.                 $entry_zone_id = $zone_query->fields['zone_id'];
  217.               } else {
  218.                 $error = true;
  219.                 $entry_state_error = true;
  220.               }
  221.             } else {
  222.               if (strlen($entry_state) < (int)ENTRY_STATE_MIN_LENGTH) {
  223.                 $error = true;
  224.                 $entry_state_error = true;
  225.               }
  226.             }
  227.          }
  228.       }
  229.  
  230.       if (strlen($customers_telephone) < ENTRY_TELEPHONE_MIN_LENGTH) {
  231.         $error = true;
  232.         $entry_telephone_error = true;
  233.       } else {
  234.         $entry_telephone_error = false;
  235.       }
  236.  
  237.       $check_email = $db->Execute("select customers_email_address
  238.                                   from " . TABLE_CUSTOMERS . "
  239.                                   where customers_email_address = '" . zen_db_input($customers_email_address) . "'
  240.                                   and customers_id != '" . (int)$customers_id . "'");
  241.  
  242.       if ($check_email->RecordCount() > 0) {
  243.         $error = true;
  244.         $entry_email_address_exists = true;
  245.       } else {
  246.         $entry_email_address_exists = false;
  247.       }
  248.  
  249.       if ($error == false) {
  250.  
  251.         $sql_data_array = array('customers_firstname' => $customers_firstname,
  252.                                 'customers_lastname' => $customers_lastname,
  253.                                 'customers_email_address' => $customers_email_address,
  254.                                 'customers_telephone' => $customers_telephone,
  255.                                 'customers_fax' => $customers_fax,
  256.                                 'customers_group_pricing' => $customers_group_pricing,
  257.                                 'customers_newsletter' => $customers_newsletter,
  258.                                 'customers_email_format' => $customers_email_format,
  259.                                 'customers_authorization' => $customers_authorization,
  260.                                 'customers_referral' => $customers_referral
  261.                                 );
  262.  
  263.         if (ACCOUNT_GENDER == 'true') $sql_data_array['customers_gender'] = $customers_gender;
  264.         if (ACCOUNT_DOB == 'true') $sql_data_array['customers_dob'] = ($customers_dob == '0001-01-01 00:00:00' ? '0001-01-01 00:00:00' : zen_date_raw($customers_dob));
  265.  
  266.         zen_db_perform(TABLE_CUSTOMERS, $sql_data_array, 'update', "customers_id = '" . (int)$customers_id . "'");
  267.  
  268.         $db->Execute("update " . TABLE_CUSTOMERS_INFO . "
  269.                      set customers_info_date_account_last_modified = now()
  270.                      where customers_info_id = '" . (int)$customers_id . "'");
  271.  
  272.         if ($entry_zone_id > 0) $entry_state = '';
  273.  
  274.         $sql_data_array = array('entry_firstname' => $customers_firstname,
  275.                                 'entry_lastname' => $customers_lastname,
  276.                                 'entry_street_address' => $entry_street_address,
  277.                                 'entry_postcode' => $entry_postcode,
  278.                                 'entry_city' => $entry_city,
  279.                                 'entry_country_id' => $entry_country_id);
  280.  
  281.         if (ACCOUNT_COMPANY == 'true') $sql_data_array['entry_company'] = $entry_company;
  282.         if (ACCOUNT_SUBURB == 'true') $sql_data_array['entry_suburb'] = $entry_suburb;
  283.  
  284.         if (ACCOUNT_STATE == 'true') {
  285.           if ($entry_zone_id > 0) {
  286.             $sql_data_array['entry_zone_id'] = $entry_zone_id;
  287.             $sql_data_array['entry_state'] = '';
  288.           } else {
  289.             $sql_data_array['entry_zone_id'] = '0';
  290.             $sql_data_array['entry_state'] = $entry_state;
  291.           }
  292.         }
  293.  
  294.         zen_db_perform(TABLE_ADDRESS_BOOK, $sql_data_array, 'update', "customers_id = '" . (int)$customers_id . "' and address_book_id = '" . (int)$default_address_id . "'");
  295.  
  296.         zen_redirect(zen_href_link(FILENAME_CUSTOMERS, zen_get_all_get_params(array('cID', 'action')) . 'cID=' . $customers_id, 'NONSSL'));
  297.  
  298.         } else if ($error == true) {
  299.           $cInfo = new objectInfo($_POST);
  300.           $processed = true;
  301.         }
  302.  
  303.         break;
  304.       case 'deleteconfirm':
  305.         // demo active test
  306.         if (zen_admin_demo()) {
  307.           $_GET['action']= '';
  308.           $messageStack->add_session(ERROR_ADMIN_DEMO, 'caution');
  309.           zen_redirect(zen_href_link(FILENAME_CUSTOMERS, zen_get_all_get_params(array('cID', 'action')), 'NONSSL'));
  310.         }
  311.         $customers_id = zen_db_prepare_input($_POST['cID']);
  312.  
  313.         if (isset($_POST['delete_reviews']) && ($_POST['delete_reviews'] == 'on')) {
  314.           $reviews = $db->Execute("select reviews_id
  315.                                   from " . TABLE_REVIEWS . "
  316.                                   where customers_id = '" . (int)$customers_id . "'");
  317.           while (!$reviews->EOF) {
  318.             $db->Execute("delete from " . TABLE_REVIEWS_DESCRIPTION . "
  319.                          where reviews_id = '" . (int)$reviews->fields['reviews_id'] . "'");
  320.             $reviews->MoveNext();
  321.           }
  322.  
  323.           $db->Execute("delete from " . TABLE_REVIEWS . "
  324.                        where customers_id = '" . (int)$customers_id . "'");
  325.         } else {
  326.           $db->Execute("update " . TABLE_REVIEWS . "
  327.                        set customers_id = null
  328.                        where customers_id = '" . (int)$customers_id . "'");
  329.         }
  330.  
  331.         $db->Execute("delete from " . TABLE_ADDRESS_BOOK . "
  332.                      where customers_id = '" . (int)$customers_id . "'");
  333.  
  334.         $db->Execute("delete from " . TABLE_CUSTOMERS . "
  335.                      where customers_id = '" . (int)$customers_id . "'");
  336.  
  337.         $db->Execute("delete from " . TABLE_CUSTOMERS_INFO . "
  338.                      where customers_info_id = '" . (int)$customers_id . "'");
  339.  
  340.         $db->Execute("delete from " . TABLE_CUSTOMERS_BASKET . "
  341.                      where customers_id = '" . (int)$customers_id . "'");
  342.  
  343.         $db->Execute("delete from " . TABLE_CUSTOMERS_BASKET_ATTRIBUTES . "
  344.                      where customers_id = '" . (int)$customers_id . "'");
  345.  
  346.         $db->Execute("delete from " . TABLE_WHOS_ONLINE . "
  347.                      where customer_id = '" . (int)$customers_id . "'");
  348.  
  349.  
  350.         zen_redirect(zen_href_link(FILENAME_CUSTOMERS, zen_get_all_get_params(array('cID', 'action')), 'NONSSL'));
  351.         break;
  352.       default:
  353.         $customers = $db->Execute("select c.customers_id, c.customers_gender, c.customers_firstname,
  354.                                          c.customers_lastname, c.customers_dob, c.customers_email_address,
  355.                                          a.entry_company, a.entry_street_address, a.entry_suburb,
  356.                                          a.entry_postcode, a.entry_city, a.entry_state, a.entry_zone_id,
  357.                                          a.entry_country_id, c.customers_telephone, c.customers_fax,
  358.                                          c.customers_newsletter, c.customers_default_address_id,
  359.                                          c.customers_email_format, c.customers_group_pricing,
  360.                                          c.customers_authorization, c.customers_referral
  361.                                  from " . TABLE_CUSTOMERS . " c left join " . TABLE_ADDRESS_BOOK . " a
  362.                                  on c.customers_default_address_id = a.address_book_id
  363.                                  where a.customers_id = c.customers_id
  364.                                  and c.customers_id = '" . (int)$customers_id . "'");
  365.  
  366.         $cInfo = new objectInfo($customers->fields);
  367.     }
  368.   }
  369. ?>
  370. <!doctype html public "-//W3C//DTD HTML 4.01 Transitional//EN">
  371. <html <?php echo HTML_PARAMS; ?>>
  372. <head>
  373. <meta http-equiv="Content-Type" content="text/html; charset=<?php echo CHARSET; ?>">
  374. <title><?php echo TITLE; ?></title>
  375. <link rel="stylesheet" type="text/css" href="includes/stylesheet.css">
  376. <link rel="stylesheet" type="text/css" href="includes/cssjsmenuhover.css" media="all" id="hoverJS">
  377. <script language="javascript" src="includes/menu.js"></script>
  378. <script language="javascript" src="includes/general.js"></script>
  379. <?php
  380.   if ($action == 'edit' || $action == 'update') {
  381. ?>
  382. <script language="javascript"><!--
  383.  
  384. function check_form() {
  385.   var error = 0;
  386.   var error_message = "<?php echo JS_ERROR; ?>";
  387.  
  388.   var customers_firstname = document.customers.customers_firstname.value;
  389.   var customers_lastname = document.customers.customers_lastname.value;
  390. <?php if (ACCOUNT_COMPANY == 'true') echo 'var entry_company = document.customers.entry_company.value;' . "\n"; ?>
  391. <?php if (ACCOUNT_DOB == 'true') echo 'var customers_dob = document.customers.customers_dob.value;' . "\n"; ?>
  392.   var customers_email_address = document.customers.customers_email_address.value;
  393.   var entry_street_address = document.customers.entry_street_address.value;
  394.   var entry_postcode = document.customers.entry_postcode.value;
  395.   var entry_city = document.customers.entry_city.value;
  396.   var customers_telephone = document.customers.customers_telephone.value;
  397.  
  398. <?php if (ACCOUNT_GENDER == 'true') { ?>
  399.   if (document.customers.customers_gender[0].checked || document.customers.customers_gender[1].checked) {
  400.   } else {
  401.     error_message = error_message + "<?php echo JS_GENDER; ?>";
  402.     error = 1;
  403.   }
  404. <?php } ?>
  405.  
  406.   if (customers_firstname == "" || customers_firstname.length < <?php echo ENTRY_FIRST_NAME_MIN_LENGTH; ?>) {
  407.     error_message = error_message + "<?php echo JS_FIRST_NAME; ?>";
  408.     error = 1;
  409.   }
  410.  
  411.   if (customers_lastname == "" || customers_lastname.length < <?php echo ENTRY_LAST_NAME_MIN_LENGTH; ?>) {
  412.     error_message = error_message + "<?php echo JS_LAST_NAME; ?>";
  413.     error = 1;
  414.   }
  415.  
  416. <?php if (ACCOUNT_DOB == 'true' && ENTRY_DOB_MIN_LENGTH !='') { ?>
  417.   if (customers_dob == "" || customers_dob.length < <?php echo ENTRY_DOB_MIN_LENGTH; ?>) {
  418.     error_message = error_message + "<?php echo JS_DOB; ?>";
  419.     error = 1;
  420.   }
  421. <?php } ?>
  422.  
  423.   if (customers_email_address == "" || customers_email_address.length < <?php echo ENTRY_EMAIL_ADDRESS_MIN_LENGTH; ?>) {
  424.     error_message = error_message + "<?php echo JS_EMAIL_ADDRESS; ?>";
  425.     error = 1;
  426.   }
  427.  
  428.   if (entry_street_address == "" || entry_street_address.length < <?php echo ENTRY_STREET_ADDRESS_MIN_LENGTH; ?>) {
  429.     error_message = error_message + "<?php echo JS_ADDRESS; ?>";
  430.     error = 1;
  431.   }
  432.  
  433.   if (entry_postcode == "" || entry_postcode.length < <?php echo ENTRY_POSTCODE_MIN_LENGTH; ?>) {
  434.     error_message = error_message + "<?php echo JS_POST_CODE; ?>";
  435.     error = 1;
  436.   }
  437.  
  438.   if (entry_city == "" || entry_city.length < <?php echo ENTRY_CITY_MIN_LENGTH; ?>) {
  439.     error_message = error_message + "<?php echo JS_CITY; ?>";
  440.     error = 1;
  441.   }
  442.  
  443. <?php
  444.   if (ACCOUNT_STATE == 'true') {
  445. ?>
  446.   if (document.customers.elements['entry_state'].type != "hidden") {
  447.     if (document.customers.entry_state.value == '' || document.customers.entry_state.value.length < <?php echo ENTRY_STATE_MIN_LENGTH; ?> ) {
  448.        error_message = error_message + "<?php echo JS_STATE; ?>";
  449.        error = 1;
  450.     }
  451.   }
  452. <?php
  453.   }
  454. ?>
  455.  
  456.   if (document.customers.elements['entry_country_id'].type != "hidden") {
  457.     if (document.customers.entry_country_id.value == 0) {
  458.       error_message = error_message + "<?php echo JS_COUNTRY; ?>";
  459.       error = 1;
  460.     }
  461.   }
  462.  
  463.   minTelephoneLength = <?php echo (int)ENTRY_TELEPHONE_MIN_LENGTH; ?>;
  464.   if (minTelephoneLength > 0 && customers_telephone.length < minTelephoneLength) {
  465.     error_message = error_message + "<?php echo JS_TELEPHONE; ?>";
  466.     error = 1;
  467.   }
  468.  
  469.   if (error == 1) {
  470.     alert(error_message);
  471.     return false;
  472.   } else {
  473.     return true;
  474.   }
  475. }
  476. //--></script>
  477. <?php
  478.   }
  479. ?>
  480. <script type="text/javascript">
  481.   <!--
  482.   function init()
  483.   {
  484.     cssjsmenu('navbar');
  485.     if (document.getElementById)
  486.     {
  487.       var kill = document.getElementById('hoverJS');
  488.       kill.disabled = true;
  489.     }
  490.   }
  491.   // -->
  492. </script>
  493. </head>
  494. <body onLoad="init()">
  495. <!-- header //-->
  496. <?php require(DIR_WS_INCLUDES . 'header.php'); ?>
  497. <!-- header_eof //-->
  498.  
  499. <!-- body //-->
  500. <table border="0" width="100%" cellspacing="2" cellpadding="2">
  501.   <tr>
  502. <!-- body_text //-->
  503.     <td width="100%" valign="top"><table border="0" width="100%" cellspacing="0" cellpadding="2">
  504. <?php
  505.   if ($action == 'edit' || $action == 'update') {
  506.     $newsletter_array = array(array('id' => '1', 'text' => ENTRY_NEWSLETTER_YES),
  507.                               array('id' => '0', 'text' => ENTRY_NEWSLETTER_NO));
  508. ?>
  509.       <tr>
  510.         <td><table border="0" width="100%" cellspacing="0" cellpadding="0">
  511.           <tr>
  512.             <td class="pageHeading"><?php echo HEADING_TITLE; ?></td>
  513.             <td class="pageHeading" align="right"><?php echo zen_draw_separator('pixel_trans.gif', HEADING_IMAGE_WIDTH, HEADING_IMAGE_HEIGHT); ?></td>
  514.           </tr>
  515.         </table></td>
  516.       </tr>
  517.       <tr>
  518.         <td><?php echo zen_draw_separator('pixel_trans.gif', '1', '10'); ?></td>
  519.       </tr>
  520.       <tr><?php echo zen_draw_form('customers', FILENAME_CUSTOMERS, zen_get_all_get_params(array('action')) . 'action=update', 'post', 'onsubmit="return check_form(customers);"', true) . zen_draw_hidden_field('default_address_id', $cInfo->customers_default_address_id);
  521.            echo zen_hide_session_id(); ?>
  522.         <td class="formAreaTitle"><?php echo CATEGORY_PERSONAL; ?></td>
  523.       </tr>
  524.       <tr>
  525.         <td class="formArea"><table border="0" cellspacing="2" cellpadding="2">
  526. <?php
  527.     if (ACCOUNT_GENDER == 'true') {
  528. ?>
  529.           <tr>
  530.             <td class="main"><?php echo ENTRY_GENDER; ?></td>
  531.             <td class="main">
  532. <?php
  533.     if ($error == true && $entry_gender_error == true) {
  534.       echo zen_draw_radio_field('customers_gender', 'm', false, $cInfo->customers_gender) . '&nbsp;&nbsp;' . MALE . '&nbsp;&nbsp;' . zen_draw_radio_field('customers_gender', 'f', false, $cInfo->customers_gender) . '&nbsp;&nbsp;' . FEMALE . '&nbsp;' . ENTRY_GENDER_ERROR;
  535.     } else {
  536.       echo zen_draw_radio_field('customers_gender', 'm', false, $cInfo->customers_gender) . '&nbsp;&nbsp;' . MALE . '&nbsp;&nbsp;' . zen_draw_radio_field('customers_gender', 'f', false, $cInfo->customers_gender) . '&nbsp;&nbsp;' . FEMALE;
  537.     }
  538. ?></td>
  539.           </tr>
  540. <?php
  541.     }
  542. ?>
  543.  
  544. <?php
  545.   $customers_authorization_array = array(array('id' => '0', 'text' => CUSTOMERS_AUTHORIZATION_0),
  546.                                 array('id' => '1', 'text' => CUSTOMERS_AUTHORIZATION_1),
  547.                                 array('id' => '2', 'text' => CUSTOMERS_AUTHORIZATION_2),
  548.                                 array('id' => '3', 'text' => CUSTOMERS_AUTHORIZATION_3),
  549.                                 array('id' => '4', 'text' => CUSTOMERS_AUTHORIZATION_4), // banned
  550.                                 );
  551. ?>
  552.           <tr>
  553.             <td class="main"><?php echo CUSTOMERS_AUTHORIZATION; ?></td>
  554.             <td class="main">
  555.               <?php echo zen_draw_pull_down_menu('customers_authorization', $customers_authorization_array, $cInfo->customers_authorization); ?>
  556.             </td>
  557.           </tr>
  558.  
  559.           <tr>
  560.             <td class="main"><?php echo ENTRY_FIRST_NAME; ?></td>
  561.             <td class="main">
  562. <?php
  563.   if ($error == true) {
  564.     if ($entry_firstname_error == true) {
  565.       echo zen_draw_input_field('customers_firstname', htmlspecialchars($cInfo->customers_firstname, ENT_COMPAT, CHARSET, TRUE), zen_set_field_length(TABLE_CUSTOMERS, 'customers_firstname', 50)) . '&nbsp;' . ENTRY_FIRST_NAME_ERROR;
  566.     } else {
  567.       echo $cInfo->customers_firstname . zen_draw_hidden_field('customers_firstname');
  568.     }
  569.   } else {
  570.     echo zen_draw_input_field('customers_firstname', htmlspecialchars($cInfo->customers_firstname, ENT_COMPAT, CHARSET, TRUE), zen_set_field_length(TABLE_CUSTOMERS, 'customers_firstname', 50), true);
  571.   }
  572. ?></td>
  573.           </tr>
  574.           <tr>
  575.             <td class="main"><?php echo ENTRY_LAST_NAME; ?></td>
  576.             <td class="main">
  577. <?php
  578.   if ($error == true) {
  579.     if ($entry_lastname_error == true) {
  580.       echo zen_draw_input_field('customers_lastname', htmlspecialchars($cInfo->customers_lastname, ENT_COMPAT, CHARSET, TRUE), zen_set_field_length(TABLE_CUSTOMERS, 'customers_lastname', 50)) . '&nbsp;' . ENTRY_LAST_NAME_ERROR;
  581.     } else {
  582.       echo $cInfo->customers_lastname . zen_draw_hidden_field('customers_lastname');
  583.     }
  584.   } else {
  585.     echo zen_draw_input_field('customers_lastname', htmlspecialchars($cInfo->customers_lastname, ENT_COMPAT, CHARSET, TRUE), zen_set_field_length(TABLE_CUSTOMERS, 'customers_lastname', 50), true);
  586.   }
  587. ?></td>
  588.           </tr>
  589. <?php
  590.     if (ACCOUNT_DOB == 'true') {
  591. ?>
  592.           <tr>
  593.             <td class="main"><?php echo ENTRY_DATE_OF_BIRTH; ?></td>
  594.             <td class="main">
  595.  
  596. <?php
  597.     if ($error == true) {
  598.       if ($entry_date_of_birth_error == true) {
  599.         echo zen_draw_input_field('customers_dob', ($cInfo->customers_dob == '0001-01-01 00:00:00' ? '' : zen_date_short($cInfo->customers_dob)), 'maxlength="10"') . '&nbsp;' . ENTRY_DATE_OF_BIRTH_ERROR;
  600.       } else {
  601.         echo $cInfo->customers_dob . ($customers_dob == '0001-01-01 00:00:00' ? 'N/A' : zen_draw_hidden_field('customers_dob'));
  602.       }
  603.     } else {
  604.       echo zen_draw_input_field('customers_dob', ($customers_dob == '0001-01-01 00:00:00' ? '' : zen_date_short($cInfo->customers_dob)), 'maxlength="10"', true);
  605.     }
  606. ?></td>
  607.           </tr>
  608. <?php
  609.     }
  610. ?>
  611.           <tr>
  612.             <td class="main"><?php echo ENTRY_EMAIL_ADDRESS; ?></td>
  613.             <td class="main">
  614. <?php
  615.   if ($error == true) {
  616.     if ($entry_email_address_error == true) {
  617.       echo zen_draw_input_field('customers_email_address', htmlspecialchars($cInfo->customers_email_address, ENT_COMPAT, CHARSET, TRUE), zen_set_field_length(TABLE_CUSTOMERS, 'customers_email_address', 50)) . '&nbsp;' . ENTRY_EMAIL_ADDRESS_ERROR;
  618.     } elseif ($entry_email_address_check_error == true) {
  619.       echo zen_draw_input_field('customers_email_address', htmlspecialchars($cInfo->customers_email_address, ENT_COMPAT, CHARSET, TRUE), zen_set_field_length(TABLE_CUSTOMERS, 'customers_email_address', 50)) . '&nbsp;' . ENTRY_EMAIL_ADDRESS_CHECK_ERROR;
  620.     } elseif ($entry_email_address_exists == true) {
  621.       echo zen_draw_input_field('customers_email_address', htmlspecialchars($cInfo->customers_email_address, ENT_COMPAT, CHARSET, TRUE), zen_set_field_length(TABLE_CUSTOMERS, 'customers_email_address', 50)) . '&nbsp;' . ENTRY_EMAIL_ADDRESS_ERROR_EXISTS;
  622.     } else {
  623.       echo $customers_email_address . zen_draw_hidden_field('customers_email_address');
  624.     }
  625.   } else {
  626.     echo zen_draw_input_field('customers_email_address', htmlspecialchars($cInfo->customers_email_address, ENT_COMPAT, CHARSET, TRUE), zen_set_field_length(TABLE_CUSTOMERS, 'customers_email_address', 50), true);
  627.   }
  628. ?></td>
  629.           </tr>
  630.         </table></td>
  631.       </tr>
  632. <?php
  633.     if (ACCOUNT_COMPANY == 'true') {
  634. ?>
  635.       <tr>
  636.         <td><?php echo zen_draw_separator('pixel_trans.gif', '1', '10'); ?></td>
  637.       </tr>
  638.       <tr>
  639.         <td class="formAreaTitle"><?php echo CATEGORY_COMPANY; ?></td>
  640.       </tr>
  641.       <tr>
  642.         <td class="formArea"><table border="0" cellspacing="2" cellpadding="2">
  643.           <tr>
  644.             <td class="main"><?php echo ENTRY_COMPANY; ?></td>
  645.             <td class="main">
  646. <?php
  647.     if ($error == true) {
  648.       if ($entry_company_error == true) {
  649.         echo zen_draw_input_field('entry_company', htmlspecialchars($cInfo->entry_company, ENT_COMPAT, CHARSET, TRUE), zen_set_field_length(TABLE_ADDRESS_BOOK, 'entry_company', 50)) . '&nbsp;' . ENTRY_COMPANY_ERROR;
  650.       } else {
  651.         echo $cInfo->entry_company . zen_draw_hidden_field('entry_company');
  652.       }
  653.     } else {
  654.       echo zen_draw_input_field('entry_company', htmlspecialchars($cInfo->entry_company, ENT_COMPAT, CHARSET, TRUE), zen_set_field_length(TABLE_ADDRESS_BOOK, 'entry_company', 50));
  655.     }
  656. ?></td>
  657.           </tr>
  658.         </table></td>
  659.       </tr>
  660. <?php
  661.     }
  662. ?>
  663.       <tr>
  664.         <td><?php echo zen_draw_separator('pixel_trans.gif', '1', '10'); ?></td>
  665.       </tr>
  666.       <tr>
  667.         <td class="formAreaTitle"><?php echo CATEGORY_ADDRESS; ?></td>
  668.       </tr>
  669.       <tr>
  670.         <td class="formArea"><table border="0" cellspacing="2" cellpadding="2">
  671.           <tr>
  672.             <td class="main"><?php echo ENTRY_STREET_ADDRESS; ?></td>
  673.             <td class="main">
  674. <?php
  675.   if ($error == true) {
  676.     if ($entry_street_address_error == true) {
  677.       echo zen_draw_input_field('entry_street_address', htmlspecialchars($cInfo->entry_street_address, ENT_COMPAT, CHARSET, TRUE), zen_set_field_length(TABLE_ADDRESS_BOOK, 'entry_street_address', 50)) . '&nbsp;' . ENTRY_STREET_ADDRESS_ERROR;
  678.     } else {
  679.       echo $cInfo->entry_street_address . zen_draw_hidden_field('entry_street_address');
  680.     }
  681.   } else {
  682.     echo zen_draw_input_field('entry_street_address', htmlspecialchars($cInfo->entry_street_address, ENT_COMPAT, CHARSET, TRUE), zen_set_field_length(TABLE_ADDRESS_BOOK, 'entry_street_address', 50), true);
  683.   }
  684. ?></td>
  685.           </tr>
  686. <?php
  687.     if (ACCOUNT_SUBURB == 'true') {
  688. ?>
  689.           <tr>
  690.             <td class="main"><?php echo ENTRY_SUBURB; ?></td>
  691.             <td class="main">
  692. <?php
  693.     if ($error == true) {
  694.       if ($entry_suburb_error == true) {
  695.         echo zen_draw_input_field('suburb', htmlspecialchars($cInfo->entry_suburb, ENT_COMPAT, CHARSET, TRUE), zen_set_field_length(TABLE_ADDRESS_BOOK, 'entry_suburb', 50)) . '&nbsp;' . ENTRY_SUBURB_ERROR;
  696.       } else {
  697.         echo $cInfo->entry_suburb . zen_draw_hidden_field('entry_suburb');
  698.       }
  699.     } else {
  700.       echo zen_draw_input_field('entry_suburb', htmlspecialchars($cInfo->entry_suburb, ENT_COMPAT, CHARSET, TRUE), zen_set_field_length(TABLE_ADDRESS_BOOK, 'entry_suburb', 50));
  701.     }
  702. ?></td>
  703.           </tr>
  704. <?php
  705.     }
  706. ?>
  707.           <tr>
  708.             <td class="main"><?php echo ENTRY_POST_CODE; ?></td>
  709.             <td class="main">
  710. <?php
  711.   if ($error == true) {
  712.     if ($entry_post_code_error == true) {
  713.       echo zen_draw_input_field('entry_postcode', htmlspecialchars($cInfo->entry_postcode, ENT_COMPAT, CHARSET, TRUE), zen_set_field_length(TABLE_ADDRESS_BOOK, 'entry_postcode', 10)) . '&nbsp;' . ENTRY_POST_CODE_ERROR;
  714.     } else {
  715.       echo $cInfo->entry_postcode . zen_draw_hidden_field('entry_postcode');
  716.     }
  717.   } else {
  718.     echo zen_draw_input_field('entry_postcode', htmlspecialchars($cInfo->entry_postcode, ENT_COMPAT, CHARSET, TRUE), zen_set_field_length(TABLE_ADDRESS_BOOK, 'entry_postcode', 10), true);
  719.   }
  720. ?></td>
  721.           </tr>
  722.           <tr>
  723.             <td class="main"><?php echo ENTRY_CITY; ?></td>
  724.             <td class="main">
  725. <?php
  726.   if ($error == true) {
  727.     if ($entry_city_error == true) {
  728.       echo zen_draw_input_field('entry_city', htmlspecialchars($cInfo->entry_city, ENT_COMPAT, CHARSET, TRUE), zen_set_field_length(TABLE_ADDRESS_BOOK, 'entry_city', 50)) . '&nbsp;' . ENTRY_CITY_ERROR;
  729.     } else {
  730.       echo $cInfo->entry_city . zen_draw_hidden_field('entry_city');
  731.     }
  732.   } else {
  733.     echo zen_draw_input_field('entry_city', htmlspecialchars($cInfo->entry_city, ENT_COMPAT, CHARSET, TRUE), zen_set_field_length(TABLE_ADDRESS_BOOK, 'entry_city', 50), true);
  734.   }
  735. ?></td>
  736.           </tr>
  737. <?php
  738.     if (ACCOUNT_STATE == 'true') {
  739. ?>
  740.           <tr>
  741.             <td class="main"><?php echo ENTRY_STATE; ?></td>
  742.             <td class="main">
  743. <?php
  744.     $entry_state = zen_get_zone_name($cInfo->entry_country_id, $cInfo->entry_zone_id, $cInfo->entry_state);
  745.     if ($error == true) {
  746.       if ($entry_state_error == true) {
  747.         if ($entry_state_has_zones == true) {
  748.           $zones_array = array();
  749.           $zones_values = $db->Execute("select zone_name
  750.                                        from " . TABLE_ZONES . "
  751.                                        where zone_country_id = '" . zen_db_input($cInfo->entry_country_id) . "'
  752.                                        order by zone_name");
  753.  
  754.           while (!$zones_values->EOF) {
  755.             $zones_array[] = array('id' => $zones_values->fields['zone_name'], 'text' => $zones_values->fields['zone_name']);
  756.             $zones_values->MoveNext();
  757.           }
  758.           echo zen_draw_pull_down_menu('entry_state', $zones_array) . '&nbsp;' . ENTRY_STATE_ERROR;
  759.         } else {
  760.           echo zen_draw_input_field('entry_state', htmlspecialchars(zen_get_zone_name($cInfo->entry_country_id, $cInfo->entry_zone_id, $cInfo->entry_state), ENT_COMPAT, CHARSET, TRUE)) . '&nbsp;' . ENTRY_STATE_ERROR;
  761.         }
  762.       } else {
  763.         echo $entry_state . zen_draw_hidden_field('entry_zone_id') . zen_draw_hidden_field('entry_state');
  764.       }
  765.     } else {
  766.       echo zen_draw_input_field('entry_state', htmlspecialchars(zen_get_zone_name($cInfo->entry_country_id, $cInfo->entry_zone_id, $cInfo->entry_state), ENT_COMPAT, CHARSET, TRUE));
  767.     }
  768.  
  769. ?></td>
  770.          </tr>
  771. <?php
  772.     }
  773. ?>
  774.           <tr>
  775.             <td class="main"><?php echo ENTRY_COUNTRY; ?></td>
  776.             <td class="main">
  777. <?php
  778.   if ($error == true) {
  779.     if ($entry_country_error == true) {
  780.       echo zen_draw_pull_down_menu('entry_country_id', zen_get_countries(), $cInfo->entry_country_id) . '&nbsp;' . ENTRY_COUNTRY_ERROR;
  781.     } else {
  782.       echo zen_get_country_name($cInfo->entry_country_id) . zen_draw_hidden_field('entry_country_id');
  783.     }
  784.   } else {
  785.     echo zen_draw_pull_down_menu('entry_country_id', zen_get_countries(), $cInfo->entry_country_id);
  786.   }
  787. ?></td>
  788.           </tr>
  789.         </table></td>
  790.       </tr>
  791.       <tr>
  792.         <td><?php echo zen_draw_separator('pixel_trans.gif', '1', '10'); ?></td>
  793.       </tr>
  794.       <tr>
  795.         <td class="formAreaTitle"><?php echo CATEGORY_CONTACT; ?></td>
  796.       </tr>
  797.       <tr>
  798.         <td class="formArea"><table border="0" cellspacing="2" cellpadding="2">
  799.           <tr>
  800.             <td class="main"><?php echo ENTRY_TELEPHONE_NUMBER; ?></td>
  801.             <td class="main">
  802. <?php
  803.   if ($error == true) {
  804.     if ($entry_telephone_error == true) {
  805.       echo zen_draw_input_field('customers_telephone', htmlspecialchars($cInfo->customers_telephone, ENT_COMPAT, CHARSET, TRUE), zen_set_field_length(TABLE_CUSTOMERS, 'customers_telephone', 15)) . '&nbsp;' . ENTRY_TELEPHONE_NUMBER_ERROR;
  806.     } else {
  807.       echo $cInfo->customers_telephone . zen_draw_hidden_field('customers_telephone');
  808.     }
  809.   } else {
  810.     echo zen_draw_input_field('customers_telephone', htmlspecialchars($cInfo->customers_telephone, ENT_COMPAT, CHARSET, TRUE), zen_set_field_length(TABLE_CUSTOMERS, 'customers_telephone', 15), true);
  811.   }
  812. ?></td>
  813.           </tr>
  814. <?php
  815.   if (ACCOUNT_FAX_NUMBER == 'true') {
  816. ?>
  817.           <tr>
  818.             <td class="main"><?php echo ENTRY_FAX_NUMBER; ?></td>
  819.             <td class="main">
  820. <?php
  821.   if ($processed == true) {
  822.     echo $cInfo->customers_fax . zen_draw_hidden_field('customers_fax');
  823.   } else {
  824.     echo zen_draw_input_field('customers_fax', htmlspecialchars($cInfo->customers_fax, ENT_COMPAT, CHARSET, TRUE), zen_set_field_length(TABLE_CUSTOMERS, 'customers_fax', 15));
  825.   }
  826. ?></td>
  827.           </tr>
  828. <?php } ?>
  829.         </table></td>
  830.       </tr>
  831.       <tr>
  832.         <td><?php echo zen_draw_separator('pixel_trans.gif', '1', '10'); ?></td>
  833.       </tr>
  834.       <tr>
  835.         <td class="formAreaTitle"><?php echo CATEGORY_OPTIONS; ?></td>
  836.       </tr>
  837.       <tr>
  838.         <td class="formArea"><table border="0" cellspacing="2" cellpadding="2">
  839.  
  840.       <tr>
  841.         <td class="main"><?php echo ENTRY_EMAIL_PREFERENCE; ?></td>
  842.         <td class="main">
  843. <?php
  844. if ($processed == true) {
  845.   if ($cInfo->customers_email_format) {
  846.     echo $customers_email_format . zen_draw_hidden_field('customers_email_format');
  847.   }
  848. } else {
  849.     $email_pref_text = ($cInfo->customers_email_format == 'TEXT') ? true : false;
  850.   $email_pref_html = !$email_pref_text;
  851.   echo zen_draw_radio_field('customers_email_format', 'HTML', $email_pref_html) . '&nbsp;' . ENTRY_EMAIL_HTML_DISPLAY . '&nbsp;&nbsp;&nbsp;' . zen_draw_radio_field('customers_email_format', 'TEXT', $email_pref_text) . '&nbsp;' . ENTRY_EMAIL_TEXT_DISPLAY ;
  852. }
  853. ?></td>
  854.       </tr>
  855.           <tr>
  856.             <td class="main"><?php echo ENTRY_NEWSLETTER; ?></td>
  857.             <td class="main">
  858. <?php
  859.   if ($processed == true) {
  860.     if ($cInfo->customers_newsletter == '1') {
  861.       echo ENTRY_NEWSLETTER_YES;
  862.     } else {
  863.       echo ENTRY_NEWSLETTER_NO;
  864.     }
  865.     echo zen_draw_hidden_field('customers_newsletter');
  866.   } else {
  867.     echo zen_draw_pull_down_menu('customers_newsletter', $newsletter_array, (($cInfo->customers_newsletter == '1') ? '1' : '0'));
  868.   }
  869. ?></td>
  870.           </tr>
  871.           <tr>
  872.             <td class="main"><?php echo ENTRY_PRICING_GROUP; ?></td>
  873.             <td class="main">
  874. <?php
  875.   if ($processed == true) {
  876.     if ($cInfo->customers_group_pricing) {
  877.       $group_query = $db->Execute("select group_name, group_percentage from " . TABLE_GROUP_PRICING . " where group_id = '" . (int)$cInfo->customers_group_pricing . "'");
  878.       echo $group_query->fields['group_name'].'&nbsp;'.$group_query->fields['group_percentage'].'%';
  879.     } else {
  880.       echo ENTRY_NONE;
  881.     }
  882.     echo zen_draw_hidden_field('customers_group_pricing', $cInfo->customers_group_pricing);
  883.   } else {
  884.     $group_array_query = $db->execute("select group_id, group_name, group_percentage from " . TABLE_GROUP_PRICING);
  885.     $group_array[] = array('id'=>0, 'text'=>TEXT_NONE);
  886.     while (!$group_array_query->EOF) {
  887.       $group_array[] = array('id'=>$group_array_query->fields['group_id'], 'text'=>$group_array_query->fields['group_name'].'&nbsp;'.$group_array_query->fields['group_percentage'].'%');
  888.       $group_array_query->MoveNext();
  889.     }
  890.     echo zen_draw_pull_down_menu('customers_group_pricing', $group_array, $cInfo->customers_group_pricing);
  891.   }
  892. ?></td>
  893.           </tr>
  894.  
  895.           <tr>
  896.             <td class="main"><?php echo CUSTOMERS_REFERRAL; ?></td>
  897.             <td class="main">
  898.               <?php echo zen_draw_input_field('customers_referral', htmlspecialchars($cInfo->customers_referral, ENT_COMPAT, CHARSET, TRUE), zen_set_field_length(TABLE_CUSTOMERS, 'customers_referral', 15)); ?>
  899.             </td>
  900.           </tr>
  901.         </table></td>
  902.       </tr>
  903.  
  904.       <tr>
  905.         <td><?php echo zen_draw_separator('pixel_trans.gif', '1', '10'); ?></td>
  906.       </tr>
  907.       <tr>
  908.         <td align="right" class="main"><?php echo zen_image_submit('button_update.gif', IMAGE_UPDATE) . ' <a href="' . zen_href_link(FILENAME_CUSTOMERS, zen_get_all_get_params(array('action')), 'NONSSL') .'">' . zen_image_button('button_cancel.gif', IMAGE_CANCEL) . '</a>'; ?></td>
  909.       </tr></form>
  910. <?php
  911.   } else {
  912. ?>
  913.       <tr>
  914.         <td><table border="0" width="100%" cellspacing="0" cellpadding="0">
  915.           <tr><?php echo zen_draw_form('search', FILENAME_CUSTOMERS, '', 'get', '', true); ?>
  916.             <td class="pageHeading"><?php echo HEADING_TITLE; ?></td>
  917.             <td class="pageHeading" align="right"><?php echo zen_draw_separator('pixel_trans.gif', 1, HEADING_IMAGE_HEIGHT); ?></td>
  918.             <td class="smallText" align="right">
  919. <?php
  920. // show reset search
  921.     if (isset($_GET['search']) && zen_not_null($_GET['search'])) {
  922.       echo '<a href="' . zen_href_link(FILENAME_CUSTOMERS, '', 'NONSSL') . '">' . zen_image_button('button_reset.gif', IMAGE_RESET) . '</a>&nbsp;&nbsp;';
  923.     }
  924.     echo HEADING_TITLE_SEARCH_DETAIL . ' ' . zen_draw_input_field('search') . zen_hide_session_id();
  925.     if (isset($_GET['search']) && zen_not_null($_GET['search'])) {
  926.       $keywords = zen_db_prepare_input($_GET['search']);
  927.       echo '<br/ >' . TEXT_INFO_SEARCH_DETAIL_FILTER . zen_output_string_protected($keywords);
  928.     }
  929. ?>
  930.             </td>
  931.           </form></tr>
  932.         </table></td>
  933.       </tr>
  934.       <tr>
  935.         <td><table border="0" width="100%" cellspacing="0" cellpadding="0">
  936.           <tr>
  937. <?php
  938. // Sort Listing
  939.           switch ($_GET['list_order']) {
  940.               case "id-asc":
  941.               $disp_order = "ci.customers_info_date_account_created";
  942.               break;
  943.               case "firstname":
  944.               $disp_order = "c.customers_firstname";
  945.               break;
  946.               case "firstname-desc":
  947.               $disp_order = "c.customers_firstname DESC";
  948.               break;
  949.               case "group-asc":
  950.               $disp_order = "c.customers_group_pricing";
  951.               break;
  952.               case "group-desc":
  953.               $disp_order = "c.customers_group_pricing DESC";
  954.               break;
  955.               case "lastname":
  956.               $disp_order = "c.customers_lastname, c.customers_firstname";
  957.               break;
  958.               case "lastname-desc":
  959.               $disp_order = "c.customers_lastname DESC, c.customers_firstname";
  960.               break;
  961.               case "company":
  962.               $disp_order = "a.entry_company";
  963.               break;
  964.               case "company-desc":
  965.               $disp_order = "a.entry_company DESC";
  966.               break;
  967.               case "login-asc":
  968.               $disp_order = "ci.customers_info_date_of_last_logon";
  969.               break;
  970.               case "login-desc":
  971.               $disp_order = "ci.customers_info_date_of_last_logon DESC";
  972.               break;
  973.               case "approval-asc":
  974.               $disp_order = "c.customers_authorization";
  975.               break;
  976.               case "approval-desc":
  977.               $disp_order = "c.customers_authorization DESC";
  978.               break;
  979.               case "gv_balance-asc":
  980.               $disp_order = "cgc.amount, c.customers_lastname, c.customers_firstname";
  981.               break;
  982.               case "gv_balance-desc":
  983.               $disp_order = "cgc.amount DESC, c.customers_lastname, c.customers_firstname";
  984.               break;
  985.               default:
  986.               $disp_order = "ci.customers_info_date_account_created DESC";
  987.           }
  988. ?>
  989.              <td valign="top"><table border="0" width="100%" cellspacing="0" cellpadding="2">
  990.               <tr class="dataTableHeadingRow">
  991.                 <td class="dataTableHeadingContent" align="center" valign="top">
  992.                   <?php echo TABLE_HEADING_ID; ?>
  993.                 </td>
  994.                 <td class="dataTableHeadingContent" align="left" valign="top">
  995.                   <?php echo (($_GET['list_order']=='lastname' or $_GET['list_order']=='lastname-desc') ? '<span class="SortOrderHeader">' . TABLE_HEADING_LASTNAME . '</span>' : TABLE_HEADING_LASTNAME); ?><br>
  996.                   <a href="<?php echo zen_href_link(basename($PHP_SELF) . '?list_order=lastname', '', 'NONSSL'); ?>"><?php echo ($_GET['list_order']=='lastname' ? '<span class="SortOrderHeader">Asc</span>' : '<span class="SortOrderHeaderLink">Asc</b>'); ?></a>&nbsp;
  997.                   <a href="<?php echo zen_href_link(basename($PHP_SELF) . '?list_order=lastname-desc', '', 'NONSSL'); ?>"><?php echo ($_GET['list_order']=='lastname-desc' ? '<span class="SortOrderHeader">Desc</span>' : '<span class="SortOrderHeaderLink">Desc</b>'); ?></a>
  998.                 </td>
  999.                 <td class="dataTableHeadingContent" align="left" valign="top">
  1000.                   <?php echo (($_GET['list_order']=='firstname' or $_GET['list_order']=='firstname-desc') ? '<span class="SortOrderHeader">' . TABLE_HEADING_FIRSTNAME . '</span>' : TABLE_HEADING_FIRSTNAME); ?><br>
  1001.                   <a href="<?php echo zen_href_link(basename($PHP_SELF) . '?list_order=firstname', '', 'NONSSL'); ?>"><?php echo ($_GET['list_order']=='firstname' ? '<span class="SortOrderHeader">Asc</span>' : '<span class="SortOrderHeaderLink">Asc</b>'); ?></a>&nbsp;
  1002.                   <a href="<?php echo zen_href_link(basename($PHP_SELF) . '?list_order=firstname-desc', '', 'NONSSL'); ?>"><?php echo ($_GET['list_order']=='firstname-desc' ? '<span class="SortOrderHeader">Desc</span>' : '<span class="SortOrderHeaderLink">Desc</span>'); ?></a>
  1003.                 </td>
  1004.                 <td class="dataTableHeadingContent" align="left" valign="top">
  1005.                   <?php echo (($_GET['list_order']=='company' or $_GET['list_order']=='company-desc') ? '<span class="SortOrderHeader">' . TABLE_HEADING_COMPANY . '</span>' : TABLE_HEADING_COMPANY); ?><br>
  1006.                   <a href="<?php echo zen_href_link(basename($PHP_SELF) . '?list_order=company', '', 'NONSSL'); ?>"><?php echo ($_GET['list_order']=='company' ? '<span class="SortOrderHeader">Asc</span>' : '<span class="SortOrderHeaderLink">Asc</b>'); ?></a>&nbsp;
  1007.                   <a href="<?php echo zen_href_link(basename($PHP_SELF) . '?list_order=company-desc', '', 'NONSSL'); ?>"><?php echo ($_GET['list_order']=='company-desc' ? '<span class="SortOrderHeader">Desc</span>' : '<span class="SortOrderHeaderLink">Desc</b>'); ?></a>
  1008.                 </td>
  1009.                 <td class="dataTableHeadingContent" align="left" valign="top">
  1010.                   <?php echo (($_GET['list_order']=='id-asc' or $_GET['list_order']=='id-desc') ? '<span class="SortOrderHeader">' . TABLE_HEADING_ACCOUNT_CREATED . '</span>' : TABLE_HEADING_ACCOUNT_CREATED); ?><br>
  1011.                   <a href="<?php echo zen_href_link(basename($PHP_SELF) . '?list_order=id-asc', '', 'NONSSL'); ?>"><?php echo ($_GET['list_order']=='id-asc' ? '<span class="SortOrderHeader">Asc</span>' : '<span class="SortOrderHeaderLink">Asc</b>'); ?></a>&nbsp;
  1012.                   <a href="<?php echo zen_href_link(basename($PHP_SELF) . '?list_order=id-desc', '', 'NONSSL'); ?>"><?php echo ($_GET['list_order']=='id-desc' ? '<span class="SortOrderHeader">Desc</span>' : '<span class="SortOrderHeaderLink">Desc</b>'); ?></a>
  1013.                 </td>
  1014.  
  1015.                 <td class="dataTableHeadingContent" align="left" valign="top">
  1016.                   <?php echo (($_GET['list_order']=='login-asc' or $_GET['list_order']=='login-desc') ? '<span class="SortOrderHeader">' . TABLE_HEADING_LOGIN . '</span>' : TABLE_HEADING_LOGIN); ?><br>
  1017.                   <a href="<?php echo zen_href_link(basename($PHP_SELF) . '?list_order=login-asc', '', 'NONSSL'); ?>"><?php echo ($_GET['list_order']=='login-asc' ? '<span class="SortOrderHeader">Asc</span>' : '<span class="SortOrderHeaderLink">Asc</b>'); ?></a>&nbsp;
  1018.                   <a href="<?php echo zen_href_link(basename($PHP_SELF) . '?list_order=login-desc', '', 'NONSSL'); ?>"><?php echo ($_GET['list_order']=='login-desc' ? '<span class="SortOrderHeader">Desc</span>' : '<span class="SortOrderHeaderLink">Desc</b>'); ?></a>
  1019.                 </td>
  1020.  
  1021.                 <td class="dataTableHeadingContent" align="left" valign="top">
  1022.                   <?php echo (($_GET['list_order']=='group-asc' or $_GET['list_order']=='group-desc') ? '<span class="SortOrderHeader">' . TABLE_HEADING_PRICING_GROUP . '</span>' : TABLE_HEADING_PRICING_GROUP); ?><br>
  1023.                   <a href="<?php echo zen_href_link(basename($PHP_SELF) . '?list_order=group-asc', '', 'NONSSL'); ?>"><?php echo ($_GET['list_order']=='group-asc' ? '<span class="SortOrderHeader">Asc</span>' : '<span class="SortOrderHeaderLink">Asc</b>'); ?></a>&nbsp;
  1024.                   <a href="<?php echo zen_href_link(basename($PHP_SELF) . '?list_order=group-desc', '', 'NONSSL'); ?>"><?php echo ($_GET['list_order']=='group-desc' ? '<span class="SortOrderHeader">Desc</span>' : '<span class="SortOrderHeaderLink">Desc</b>'); ?></a>
  1025.                 </td>
  1026.  
  1027. <?php if (MODULE_ORDER_TOTAL_GV_STATUS == 'true') { ?>
  1028.                 <td class="dataTableHeadingContent" align="left" valign="top" width="75">
  1029.                   <?php echo (($_GET['list_order']=='gv_balance-asc' or $_GET['list_order']=='gv_balance-desc') ? '<span class="SortOrderHeader">' . TABLE_HEADING_GV_AMOUNT . '</span>' : TABLE_HEADING_GV_AMOUNT); ?><br>
  1030.                   <a href="<?php echo zen_href_link(basename($PHP_SELF) . '?list_order=gv_balance-asc', '', 'NONSSL'); ?>"><?php echo ($_GET['list_order']=='gv_balance-asc' ? '<span class="SortOrderHeader">Asc</span>' : '<span class="SortOrderHeaderLink">Asc</b>'); ?></a>&nbsp;
  1031.                   <a href="<?php echo zen_href_link(basename($PHP_SELF) . '?list_order=gv_balance-desc', '', 'NONSSL'); ?>"><?php echo ($_GET['list_order']=='gv_balance-desc' ? '<span class="SortOrderHeader">Desc</span>' : '<span class="SortOrderHeaderLink">Desc</b>'); ?></a>
  1032.                 </td>
  1033. <?php } ?>
  1034.  
  1035.                 <td class="dataTableHeadingContent" align="center" valign="top">
  1036.                   <?php echo (($_GET['list_order']=='approval-asc' or $_GET['list_order']=='approval-desc') ? '<span class="SortOrderHeader">' . TABLE_HEADING_AUTHORIZATION_APPROVAL . '</span>' : TABLE_HEADING_AUTHORIZATION_APPROVAL); ?><br>
  1037.                   <a href="<?php echo zen_href_link(basename($PHP_SELF) . '?list_order=approval-asc', '', 'NONSSL'); ?>"><?php echo ($_GET['list_order']=='approval-asc' ? '<span class="SortOrderHeader">Asc</span>' : '<span class="SortOrderHeaderLink">Asc</b>'); ?></a>&nbsp;
  1038.                   <a href="<?php echo zen_href_link(basename($PHP_SELF) . '?list_order=approval-desc', '', 'NONSSL'); ?>"><?php echo ($_GET['list_order']=='approval-desc' ? '<span class="SortOrderHeader">Desc</span>' : '<span class="SortOrderHeaderLink">Desc</b>'); ?></a>
  1039.                 </td>
  1040.  
  1041.                 <td class="dataTableHeadingContent" align="right" valign="top"><?php echo TABLE_HEADING_ACTION; ?>&nbsp;</td>
  1042.               </tr>
  1043. <?php
  1044.     $search = '';
  1045.     if (isset($_GET['search']) && zen_not_null($_GET['search'])) {
  1046.       $keywords = zen_db_input(zen_db_prepare_input($_GET['search']));
  1047.       $search = "where c.customers_lastname like '%" . $keywords . "%' or c.customers_firstname like '%" . $keywords . "%' or c.customers_email_address like '%" . $keywords . "%' or c.customers_telephone rlike ':keywords:' or a.entry_company rlike ':keywords:' or a.entry_street_address rlike ':keywords:' or a.entry_city rlike ':keywords:' or a.entry_postcode rlike ':keywords:'";
  1048.       $search = $db->bindVars($search, ':keywords:', $keywords, 'regexp');
  1049.     }
  1050.     $new_fields=', c.customers_telephone, a.entry_company, a.entry_street_address, a.entry_city, a.entry_postcode, c.customers_authorization, c.customers_referral';
  1051.     $customers_query_raw = "select c.customers_id, c.customers_lastname, c.customers_firstname, c.customers_email_address, c.customers_group_pricing, a.entry_country_id, a.entry_company, ci.customers_info_date_of_last_logon, ci.customers_info_date_account_created " . $new_fields . ",
  1052.    cgc.amount
  1053.    from " . TABLE_CUSTOMERS . " c
  1054.    left join " . TABLE_CUSTOMERS_INFO . " ci on c.customers_id= ci.customers_info_id
  1055.    left join " . TABLE_ADDRESS_BOOK . " a on c.customers_id = a.customers_id and c.customers_default_address_id = a.address_book_id " . "
  1056.    left join " . TABLE_COUPON_GV_CUSTOMER . " cgc on c.customers_id = cgc.customer_id " .
  1057.     $search . " order by $disp_order";
  1058.  
  1059. // Split Page
  1060. // reset page when page is unknown
  1061. if (($_GET['page'] == '' or $_GET['page'] == '1') and $_GET['cID'] != '') {
  1062.   $check_page = $db->Execute($customers_query_raw);
  1063.   $check_count=1;
  1064.   if ($check_page->RecordCount() > MAX_DISPLAY_SEARCH_RESULTS_CUSTOMER) {
  1065.     while (!$check_page->EOF) {
  1066.       if ($check_page->fields['customers_id'] == $_GET['cID']) {
  1067.         break;
  1068.       }
  1069.       $check_count++;
  1070.       $check_page->MoveNext();
  1071.     }
  1072.     $_GET['page'] = round((($check_count/MAX_DISPLAY_SEARCH_RESULTS_CUSTOMER)+(fmod_round($check_count,MAX_DISPLAY_SEARCH_RESULTS_CUSTOMER) !=0 ? .5 : 0)),0);
  1073. //    zen_redirect(zen_href_link(FILENAME_CUSTOMERS, 'cID=' . $_GET['cID'] . (isset($_GET['page']) ? '&page=' . $_GET['page'] : ''), 'NONSSL'));
  1074.   } else {
  1075.     $_GET['page'] = 1;
  1076.   }
  1077. }
  1078.  
  1079.     $customers_split = new splitPageResults($_GET['page'], MAX_DISPLAY_SEARCH_RESULTS_CUSTOMER, $customers_query_raw, $customers_query_numrows);
  1080.     $customers = $db->Execute($customers_query_raw);
  1081.     while (!$customers->EOF) {
  1082.       $sql = "select customers_info_date_account_created as date_account_created,
  1083.                                   customers_info_date_account_last_modified as date_account_last_modified,
  1084.                                   customers_info_date_of_last_logon as date_last_logon,
  1085.                                   customers_info_number_of_logons as number_of_logons
  1086.                            from " . TABLE_CUSTOMERS_INFO . "
  1087.                            where customers_info_id = '" . $customers->fields['customers_id'] . "'";
  1088.       $info = $db->Execute($sql);
  1089.  
  1090.       // if no record found, create one to keep database in sync
  1091.       if (!isset($info->fields) || !is_array($info->fields)) {
  1092.         $insert_sql = "insert into " . TABLE_CUSTOMERS_INFO . " (customers_info_id, customers_info_number_of_logons, customers_info_date_account_created)
  1093.                       values ('" . (int)$customers->fields['customers_id'] . "', '0', now())";
  1094.         $db->Execute($insert_sql);
  1095.         $info = $db->Execute($sql);
  1096.       }
  1097.  
  1098.       if ((!isset($_GET['cID']) || (isset($_GET['cID']) && ($_GET['cID'] == $customers->fields['customers_id']))) && !isset($cInfo)) {
  1099.         $country = $db->Execute("select countries_name
  1100.                                 from " . TABLE_COUNTRIES . "
  1101.                                 where countries_id = '" . (int)$customers->fields['entry_country_id'] . "'");
  1102.  
  1103.         $reviews = $db->Execute("select count(*) as number_of_reviews
  1104.                                 from " . TABLE_REVIEWS . " where customers_id = '" . (int)$customers->fields['customers_id'] . "'");
  1105.  
  1106.         $customer_info = array_merge($country->fields, $info->fields, $reviews->fields);
  1107.  
  1108.         $cInfo_array = array_merge($customers->fields, $customer_info);
  1109.         $cInfo = new objectInfo($cInfo_array);
  1110.       }
  1111.  
  1112.         $group_query = $db->Execute("select group_name, group_percentage from " . TABLE_GROUP_PRICING . " where
  1113.                                     group_id = '" . $customers->fields['customers_group_pricing'] . "'");
  1114.  
  1115.         if ($group_query->RecordCount() < 1) {
  1116.           $group_name_entry = TEXT_NONE;
  1117.         } else {
  1118.           $group_name_entry = $group_query->fields['group_name'];
  1119.         }
  1120.  
  1121.       if (isset($cInfo) && is_object($cInfo) && ($customers->fields['customers_id'] == $cInfo->customers_id)) {
  1122.         echo '          <tr id="defaultSelected" class="dataTableRowSelected" onmouseover="rowOverEffect(this)" onmouseout="rowOutEffect(this)" onclick="document.location.href=\'' . zen_href_link(FILENAME_CUSTOMERS, zen_get_all_get_params(array('cID', 'action')) . 'cID=' . $cInfo->customers_id . '&action=edit', 'NONSSL') . '\'">' . "\n";
  1123.       } else {
  1124.         echo '          <tr class="dataTableRow" onmouseover="rowOverEffect(this)" onmouseout="rowOutEffect(this)" onclick="document.location.href=\'' . zen_href_link(FILENAME_CUSTOMERS, zen_get_all_get_params(array('cID')) . 'cID=' . $customers->fields['customers_id'], 'NONSSL') . '\'">' . "\n";
  1125.       }
  1126.  
  1127.       $zc_address_book_count_list = zen_get_customers_address_book($customers->fields['customers_id']);
  1128.       $zc_address_book_count = $zc_address_book_count_list->RecordCount();
  1129. ?>
  1130.                 <td class="dataTableContent" align="right"><?php echo $customers->fields['customers_id'] . ($zc_address_book_count == 1 ? TEXT_INFO_ADDRESS_BOOK_COUNT . $zc_address_book_count : '<a href="' . zen_href_link(FILENAME_CUSTOMERS, 'action=list_addresses' . '&cID=' . $customers->fields['customers_id'] . ($_GET['page'] > 0 ? '&page=' . $_GET['page'] : ''), 'NONSSL') . '">' . TEXT_INFO_ADDRESS_BOOK_COUNT . $zc_address_book_count . '</a>'); ?></td>
  1131.                 <td class="dataTableContent"><?php echo $customers->fields['customers_lastname']; ?></td>
  1132.                 <td class="dataTableContent"><?php echo $customers->fields['customers_firstname']; ?></td>
  1133.                 <td class="dataTableContent"><?php echo $customers->fields['entry_company']; ?></td>
  1134.                 <td class="dataTableContent"><?php echo zen_date_short($info->fields['date_account_created']); ?></td>
  1135.                 <td class="dataTableContent"><?php echo zen_date_short($customers->fields['customers_info_date_of_last_logon']); ?></td>
  1136.                 <td class="dataTableContent"><?php echo $group_name_entry; ?></td>
  1137. <?php if (MODULE_ORDER_TOTAL_GV_STATUS == 'true') { ?>
  1138.                 <td class="dataTableContent" align="right"><?php echo $currencies->format($customers->fields['amount']); ?></td>
  1139. <?php } ?>
  1140.                 <td class="dataTableContent" align="center">
  1141.                 <?php if ($customers->fields['customers_authorization'] == 4) { ?>
  1142.                 <?php echo zen_image(DIR_WS_IMAGES . 'icon_red_off.gif', IMAGE_ICON_STATUS_OFF); ?>
  1143.                 <?php } else { ?>
  1144.                   <?php if ($customers->fields['customers_authorization'] == 0) {
  1145.                     echo zen_draw_form('setstatus', FILENAME_CUSTOMERS, 'action=status&cID=' . $customers->fields['customers_id'] . (isset($_GET['page']) ? '&page=' . $_GET['page'] : '') . (isset($_GET['search']) ? '&search=' . $_GET['search'] : ''));?>
  1146.                     <input type="image" src="<?php echo DIR_WS_IMAGES ?>icon_green_on.gif" title="<?php echo IMAGE_ICON_STATUS_ON; ?>" />
  1147.                     <input type="hidden" name="current" value="<?php echo $customers->fields['customers_authorization']; ?>" />
  1148.                     </form>
  1149.                   <?php } else {
  1150.                     echo zen_draw_form('setstatus', FILENAME_CUSTOMERS, 'action=status&cID=' . $customers->fields['customers_id'] . (isset($_GET['page']) ? '&page=' . $_GET['page'] : '') . (isset($_GET['search']) ? '&search=' . $_GET['search'] : ''));?>
  1151.                     <input type="image" src="<?php echo DIR_WS_IMAGES ?>icon_red_on.gif" title="<?php echo IMAGE_ICON_STATUS_OFF; ?>" />
  1152.                     <input type="hidden" name="current" value="<?php echo $customers->fields['customers_authorization']; ?>" />
  1153.                     </form>
  1154.                   <?php } ?>
  1155.                 <?php } ?>
  1156.                 </td>
  1157.                 <td class="dataTableContent" align="right"><?php if (isset($cInfo) && is_object($cInfo) && ($customers->fields['customers_id'] == $cInfo->customers_id)) { echo zen_image(DIR_WS_IMAGES . 'icon_arrow_right.gif', ''); } else { echo '<a href="' . zen_href_link(FILENAME_CUSTOMERS, zen_get_all_get_params(array('cID')) . 'cID=' . $customers->fields['customers_id'] . ($_GET['page'] > 0 ? '&page=' . $_GET['page'] : ''), 'NONSSL') . '">' . zen_image(DIR_WS_IMAGES . 'icon_info.gif', IMAGE_ICON_INFO) . '</a>'; } ?>&nbsp;</td>
  1158.               </tr>
  1159. <?php
  1160.       $customers->MoveNext();
  1161.     }
  1162. ?>
  1163.               <tr>
  1164.                 <td colspan="5"><table border="0" width="100%" cellspacing="0" cellpadding="2">
  1165.                   <tr>
  1166.                     <td class="smallText" valign="top"><?php echo $customers_split->display_count($customers_query_numrows, MAX_DISPLAY_SEARCH_RESULTS_CUSTOMER, $_GET['page'], TEXT_DISPLAY_NUMBER_OF_CUSTOMERS); ?></td>
  1167.                     <td class="smallText" align="right"><?php echo $customers_split->display_links($customers_query_numrows, MAX_DISPLAY_SEARCH_RESULTS_CUSTOMER, MAX_DISPLAY_PAGE_LINKS, $_GET['page'], zen_get_all_get_params(array('page', 'info', 'x', 'y', 'cID'))); ?></td>
  1168.                   </tr>
  1169. <?php
  1170.     if (isset($_GET['search']) && zen_not_null($_GET['search'])) {
  1171. ?>
  1172.                   <tr>
  1173.                     <td align="right" colspan="2"><?php echo '<a href="' . zen_href_link(FILENAME_CUSTOMERS, '', 'NONSSL') . '">' . zen_image_button('button_reset.gif', IMAGE_RESET) . '</a>'; ?></td>
  1174.                   </tr>
  1175. <?php
  1176.     }
  1177. ?>
  1178.                 </table></td>
  1179.               </tr>
  1180.             </table></td>
  1181. <?php
  1182.   $heading = array();
  1183.   $contents = array();
  1184.  
  1185.   switch ($action) {
  1186.     case 'confirm':
  1187.       $heading[] = array('text' => '<b>' . TEXT_INFO_HEADING_DELETE_CUSTOMER . '</b>');
  1188.  
  1189.       $contents = array('form' => zen_draw_form('customers', FILENAME_CUSTOMERS, zen_get_all_get_params(array('cID', 'action', 'search')) . 'action=deleteconfirm', 'post', '', true) . zen_draw_hidden_field('cID', $cInfo->customers_id));
  1190.       $contents[] = array('text' => TEXT_DELETE_INTRO . '<br><br><b>' . $cInfo->customers_firstname . ' ' . $cInfo->customers_lastname . '</b>');
  1191.       if (isset($cInfo->number_of_reviews) && ($cInfo->number_of_reviews) > 0) $contents[] = array('text' => '<br />' . zen_draw_checkbox_field('delete_reviews', 'on', true) . ' ' . sprintf(TEXT_DELETE_REVIEWS, $cInfo->number_of_reviews));
  1192.       $contents[] = array('align' => 'center', 'text' => '<br />' . zen_image_submit('button_delete.gif', IMAGE_DELETE) . ' <a href="' . zen_href_link(FILENAME_CUSTOMERS, zen_get_all_get_params(array('cID', 'action')) . 'cID=' . $cInfo->customers_id, 'NONSSL') . '">' . zen_image_button('button_cancel.gif', IMAGE_CANCEL) . '</a>');
  1193.       break;
  1194.     default:
  1195.       if (isset($_GET['search'])) $_GET['search'] = zen_output_string_protected($_GET['search']);
  1196.       if (isset($cInfo) && is_object($cInfo)) {
  1197.         $customers_orders = $db->Execute("select o.orders_id, o.date_purchased, o.order_total, o.currency, o.currency_value,
  1198.                                          cgc.amount
  1199.                                          from " . TABLE_ORDERS . " o
  1200.                                          left join " . TABLE_COUPON_GV_CUSTOMER . " cgc on o.customers_id = cgc.customer_id
  1201.                                          where customers_id='" . $cInfo->customers_id . "' order by date_purchased desc");
  1202.  
  1203.         $heading[] = array('text' => '<b>' . TABLE_HEADING_ID . $cInfo->customers_id . ' ' . $cInfo->customers_firstname . ' ' . $cInfo->customers_lastname . '</b>');
  1204.  
  1205.         $contents[] = array('align' => 'center', 'text' => '<a href="' . zen_href_link(FILENAME_CUSTOMERS, zen_get_all_get_params(array('cID', 'action', 'search')) . 'cID=' . $cInfo->customers_id . '&action=edit', 'NONSSL') . '">' . zen_image_button('button_edit.gif', IMAGE_EDIT) . '</a> <a href="' . zen_href_link(FILENAME_CUSTOMERS, zen_get_all_get_params(array('cID', 'action', 'search')) . 'cID=' . $cInfo->customers_id . '&action=confirm', 'NONSSL') . '">' . zen_image_button('button_delete.gif', IMAGE_DELETE) . '</a><br />' . ($customers_orders->RecordCount() != 0 ? '<a href="' . zen_href_link(FILENAME_ORDERS, 'cID=' . $cInfo->customers_id, 'NONSSL') . '">' . zen_image_button('button_orders.gif', IMAGE_ORDERS) . '</a>' : '') . ' <a href="' . zen_href_link(FILENAME_MAIL, 'origin=customers.php&mode=NONSSL&selected_box=tools&customer=' . $cInfo->customers_email_address.'&cID=' . $cInfo->customers_id, 'NONSSL') . '">' . zen_image_button('button_email.gif', IMAGE_EMAIL) . '</a>');
  1206.         $contents[] = array('text' => '<br />' . TEXT_DATE_ACCOUNT_CREATED . ' ' . zen_date_short($cInfo->date_account_created));
  1207.         $contents[] = array('text' => '<br />' . TEXT_DATE_ACCOUNT_LAST_MODIFIED . ' ' . zen_date_short($cInfo->date_account_last_modified));
  1208.         $contents[] = array('text' => '<br />' . TEXT_INFO_DATE_LAST_LOGON . ' '  . zen_date_short($cInfo->date_last_logon));
  1209.         $contents[] = array('text' => '<br />' . TEXT_INFO_NUMBER_OF_LOGONS . ' ' . $cInfo->number_of_logons);
  1210.  
  1211.         $customer_gv_balance = zen_user_has_gv_balance($cInfo->customers_id);
  1212.         $contents[] = array('text' => '<br />' . TEXT_INFO_GV_AMOUNT . ' ' . $currencies->format($customer_gv_balance));
  1213.  
  1214.         $contents[] = array('text' => '<br />' . TEXT_INFO_NUMBER_OF_ORDERS . ' ' . $customers_orders->RecordCount());
  1215.         if ($customers_orders->RecordCount() != 0) {
  1216.           $contents[] = array('text' => TEXT_INFO_LAST_ORDER . ' ' . zen_date_short($customers_orders->fields['date_purchased']) . '<br />' . TEXT_INFO_ORDERS_TOTAL . ' ' . $currencies->format($customers_orders->fields['order_total'], true, $customers_orders->fields['currency'], $customers_orders->fields['currency_value']));
  1217.         }
  1218.         $contents[] = array('text' => '<br />' . TEXT_INFO_COUNTRY . ' ' . $cInfo->countries_name);
  1219.         $contents[] = array('text' => '<br />' . TEXT_INFO_NUMBER_OF_REVIEWS . ' ' . $cInfo->number_of_reviews);
  1220.         $contents[] = array('text' => '<br />' . CUSTOMERS_REFERRAL . ' ' . $cInfo->customers_referral);
  1221.       }
  1222.       break;
  1223.   }
  1224.  
  1225.   if ( (zen_not_null($heading)) && (zen_not_null($contents)) ) {
  1226.     echo '            <td width="25%" valign="top">' . "\n";
  1227.  
  1228.     $box = new box;
  1229.     echo $box->infoBox($heading, $contents);
  1230.  
  1231.     echo '            </td>' . "\n";
  1232.   }
  1233. ?>
  1234.           </tr>
  1235.         </table></td>
  1236.       </tr>
  1237. <?php
  1238.   }
  1239. ?>
  1240.     </table></td>
  1241. <!-- body_text_eof //-->
  1242.   </tr>
  1243. </table>
  1244. <!-- body_eof //-->
  1245.  
  1246. <!-- footer //-->
  1247. <?php require(DIR_WS_INCLUDES . 'footer.php'); ?>
  1248. <!-- footer_eof //-->
  1249. <br>
  1250. </body>
  1251. </html>
  1252. <?php require(DIR_WS_INCLUDES . 'application_bottom.php'); ?>
  1253.  


cron