[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文件
文件大小: 62.8 KiB
MD5: 209a9df490c71e4f9db9c8bc7ef307ef

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