Example #1
0
// make a new ship request
if ($action == 'ship') {
    if (!$order) {
        die(ERROR_NO_ORDER_NUMBER);
    }
    include DIR_WS_INCLUDES . 'abbreviate.php';
    // used to abbreviate state & country names
    require DIR_WS_INCLUDES . 'fedexdc.php';
    // array of characters we don't want in phone numbers
    $unwanted = array('(', ')', '-', '.', ' ');
    $transaction_code = 21;
    // 21 is a ship request
    // get the country we're shipping from
    $country_query = tep_db_query("select configuration_value from " . TABLE_CONFIGURATION . " where configuration_key = 'STORE_COUNTRY'");
    $country_value = tep_db_fetch_array($country_query);
    $country = tep_get_country_name($country_value['configuration_value']);
    // abbreviate it for fedex (United States = US etc.)
    $senders_country = abbreviate_country($country);
    // get sender's fedex info from configuration table
    // (requires installation & configuration of FedEx RealTime Quotes)
    $fedex_vars = array(10 => 'MODULE_SHIPPING_FEDEX1_ACCOUNT', 498 => 'MODULE_SHIPPING_FEDEX1_METER', 75 => 'MODULE_SHIPPING_FEDEX1_WEIGHT', 4 => 'STORE_NAME', 5 => 'MODULE_SHIPPING_FEDEX1_ADDRESS_1', 6 => 'MODULE_SHIPPING_FEDEX1_ADDRESS_2', 7 => 'MODULE_SHIPPING_FEDEX1_CITY', 8 => 'MODULE_SHIPPING_FEDEX1_STATE', 9 => 'MODULE_SHIPPING_FEDEX1_POSTAL', 183 => 'MODULE_SHIPPING_FEDEX1_PHONE', 68 => 'DEFAULT_CURRENCY');
    $i = 0;
    $fedex_keys = array_keys($fedex_vars);
    foreach ($fedex_vars as $var) {
        $value_query = tep_db_query("select configuration_value from " . TABLE_CONFIGURATION . " where configuration_key = '" . $var . "'");
        $value = tep_db_fetch_array($value_query);
        $value = $value['configuration_value'];
        if ($var == 'MODULE_SHIPPING_FEDEX1_ACCOUNT' && !$value) {
            die(ERROR_FEDEX_QUOTES_NOT_INSTALLED);
        }
        // get rid of dashes, parentheses and periods in shipper's telephone number
Example #2
0
        $customer_default_address_id = $address_id;
        $customer_country_id = $country;
        // build the message content
        $name = $firstname . ' ' . $lastname;
        $email_text = sprintf(EMAIL_GREET_NONE, $firstname);
        //CYA - Add new here
        $email_text = sprintf(EMAIL_TEMPLATE_REGISTASION, HTTP_SERVER, HTTP_SERVER, $firstname, HTTP_SERVER . DIR_WS_CATALOG . "login.php", HTTP_SERVER . DIR_WS_CATALOG . "login.php", $email_address, $password, STORE_OWNER_EMAIL_ADDRESS, STORE_OWNER_EMAIL_ADDRESS);
        tep_mail_new($name, $email_address, EMAIL_SUBJECT, $email_text, STORE_OWNER, STORE_OWNER_EMAIL_ADDRESS);
        // admin email notification
        $admin_email_text .= ADMIN_EMAIL_WELCOME . ADMIN_EMAIL_TEXT;
        // . EMAIL_WARNING;
        $row = tep_db_fetch_array(tep_db_query("select group_name from customers_groups where group_id={$group}"));
        if (isset($referral_other) && $referral_other != "") {
            $opt = ' (' . $referral_other . ')';
        }
        $admin_email_text .= "\nCustomer's info:\n" . "Name: {$firstname} {$lastname}\n" . "Company: " . $company . "\n" . "Title/Position: " . $title . "\n" . "Email: " . $email_address . "\n" . "Website: " . $website . "\n" . "Group: " . $row['group_name'] . "\n" . "Sales Territory: " . $st . "\n" . "Country: " . tep_get_country_name($country) . "\n" . "City: " . $city . "\n" . "Street Address: " . $street_address . "\n" . "Post Code: " . $postcode . "\n" . "State: " . $state . "\n" . "Telephone: {$telephone}\n" . "Telephone ext: {$customers_telephone_ext}\n" . "Fax: " . $fax . "\n" . "IP Address: " . $_SERVER['REMOTE_ADDR'] . "\n" . '<a href="http://www.ip2location.com/">http://www.ip2location.com/</a>' . "\n" . "Referral: " . $referral . $opt . "\n\n" . "Click to approve: " . HTTP_SERVER . DIR_WS_HTTP_CATALOG . "admin/members.php\n\n";
        //        tep_mail(STORE_OWNER, "*****@*****.**", EMAIL_SUBJECT, nl2br($admin_email_text), "", STORE_OWNER_EMAIL_ADDRESS);
        tep_mail(STORE_OWNER, "*****@*****.**", EMAIL_SUBJECT, nl2br($admin_email_text), "", STORE_OWNER_EMAIL_ADDRESS);
        //tep_redirect(tep_href_link(FILENAME_CREATE_ACCOUNT_SUCCESS, '', 'SSL'));
        $response['type'] = 1;
        $response['content'] = tep_href_link(FILENAME_CREATE_ACCOUNT_SUCCESS, '', 'SSL');
    } else {
        $response['type'] = 0;
        $response['message'] = $arrayErrors;
    }
    print json_encode($response);
    exit;
}
$response['type'] = 0;
$response['content'] = "Error. Please try later!";
print json_encode($response);
Example #3
0
function tep_address_format($address_format_id, $address, $html, $boln, $eoln)
{
    global $osC_Database;
    $Qformat = $osC_Database->query('select address_format from :table_address_format where address_format_id = :address_format_id');
    $Qformat->bindTable(':table_address_format', TABLE_ADDRESS_FORMAT);
    $Qformat->bindInt(':address_format_id', $address_format_id);
    $Qformat->execute();
    $company = tep_output_string_protected($address['company']);
    if (isset($address['firstname']) && tep_not_null($address['firstname'])) {
        $firstname = tep_output_string_protected($address['firstname']);
        $lastname = tep_output_string_protected($address['lastname']);
    } elseif (isset($address['name']) && tep_not_null($address['name'])) {
        $firstname = tep_output_string_protected($address['name']);
        $lastname = '';
    } else {
        $firstname = '';
        $lastname = '';
    }
    $street = tep_output_string_protected($address['street_address']);
    $suburb = tep_output_string_protected($address['suburb']);
    $city = tep_output_string_protected($address['city']);
    $state = tep_output_string_protected($address['state']);
    if (isset($address['country_id']) && tep_not_null($address['country_id'])) {
        $country = tep_get_country_name($address['country_id']);
        if (isset($address['zone_id']) && tep_not_null($address['zone_id'])) {
            $state = tep_get_zone_code($address['country_id'], $address['zone_id'], $state);
        }
    } elseif (isset($address['country']) && tep_not_null($address['country'])) {
        $country = tep_output_string_protected($address['country']);
    } else {
        $country = '';
    }
    $postcode = tep_output_string_protected($address['postcode']);
    $zip = $postcode;
    if ($html) {
        // HTML Mode
        $HR = '<hr>';
        $hr = '<hr>';
        if ($boln == '' && $eoln == "\n") {
            // Values not specified, use rational defaults
            $CR = '<br>';
            $cr = '<br>';
            $eoln = $cr;
        } else {
            // Use values supplied
            $CR = $eoln . $boln;
            $cr = $CR;
        }
    } else {
        // Text Mode
        $CR = $eoln;
        $cr = $CR;
        $HR = '----------------------------------------';
        $hr = '----------------------------------------';
    }
    $statecomma = '';
    $streets = $street;
    if ($suburb != '') {
        $streets = $street . $cr . $suburb;
    }
    if ($country == '') {
        $country = tep_output_string_protected($address['country']);
    }
    if ($state != '') {
        $statecomma = $state . ', ';
    }
    $fmt = $Qformat->value('address_format');
    eval("\$address = \"{$fmt}\";");
    if (ACCOUNT_COMPANY == 'true' && tep_not_null($company)) {
        $address = $company . $cr . $address;
    }
    return $address;
}
Example #4
0
 private function put_all_data_in_db($orders_id)
 {
     global $currency, $currencies;
     //fill orders table
     if (extension_loaded('apc') && ini_get('apc.enabled')) {
         apc_delete('temp_orders_' . $orders_id);
         apc_delete('temp_orders_products_' . $orders_id);
         apc_delete('temp_orders_status_history_' . $orders_id);
         apc_delete('temp_orders_total_' . $orders_id);
     }
     $this->get_all_data_from_temp_db($orders_id);
     $orders = $this->temp_data[$orders_id]['orders'];
     unset($orders['orders_id']);
     unset($orders['delivery_address_id']);
     unset($orders['billing_address_id']);
     unset($orders['coupon_id']);
     unset($orders['payment_method_extra']);
     unset($orders['shipping_method_extra']);
     unset($orders['processed_order_id']);
     $orders['abo_status'] = '0';
     $orders['date_purchased'] = $orders['last_modified'] = date("Y-m-d H:m:s");
     $orders['currency'] = $currency;
     $orders['currency_value'] = $currencies->currencies[$currency]['value'];
     $orders['customers_address_format_id'] = tep_get_address_format_id($orders['customers_country']);
     $orders['customers_country'] = tep_get_country_name($orders['customers_country']);
     $orders['billing_address_format_id'] = tep_get_address_format_id($orders['billing_country']);
     $orders['billing_country'] = tep_get_country_name($orders['billing_country']);
     $orders['delivery_address_format_id'] = tep_get_address_format_id($orders['delivery_country']);
     $orders['delivery_country'] = tep_get_country_name($orders['delivery_country']);
     tep_db_perform('orders', $orders, 'insert');
     $new_orders_id = tep_db_insert_id();
     //add order id to temp orders table
     tep_db_query('UPDATE temp_orders SET processed_order_id = "' . $new_orders_id . '" WHERE orders_id = "' . $orders_id . '"');
     //fill orders_products table
     $orders_products = $this->temp_data[$orders_id]['orders_products'];
     //fill orders_products_attributes
     $orders_products_attributes = $this->temp_data[$orders_id]['orders_products_attributes'];
     if (is_array($orders_products)) {
         foreach ($orders_products as $products_order_id => $data) {
             unset($orders_products[$products_order_id]['orders_products_id']);
             unset($orders_products[$products_order_id]['products_weight']);
             $orders_products[$products_order_id]['orders_id'] = $new_orders_id;
             tep_db_perform('orders_products', $orders_products[$products_order_id], 'insert');
             $orders_products_id = tep_db_insert_id();
             if (is_array($orders_products_attributes)) {
                 foreach ($orders_products_attributes[$products_order_id] as $key => $value) {
                     unset($orders_products_attributes[$products_order_id][$key]['orders_products_attributes_id']);
                     $orders_products_attributes[$products_order_id][$key]['orders_id'] = $new_orders_id;
                     $orders_products_attributes[$products_order_id][$key]['orders_products_id'] = $orders_products_id;
                     tep_db_perform('orders_products_attributes', $orders_products_attributes[$products_order_id][$key], 'insert');
                 }
             }
         }
     }
     //fill orders_products_status_history table
     $orders_status_history = $this->temp_data[$orders_id]['orders_status_history'];
     if (is_array($orders_status_history)) {
         foreach ($orders_status_history as $key => $value) {
             unset($orders_status_history[$key]['orders_status_history_id']);
             $orders_status_history[$key]['orders_id'] = $new_orders_id;
             $orders_status_history[$key]['orders_status_id'] = $orders['orders_status'];
             tep_db_perform('orders_status_history', $orders_status_history[$key], 'insert');
         }
     }
     //fill orders_total table
     $orders_total = $this->temp_data[$orders_id]['orders_total'];
     if (is_array($orders_total)) {
         foreach ($orders_total as $key => $data) {
             unset($orders_total[$key]['orders_total_id']);
             $orders_total[$key]['orders_id'] = $new_orders_id;
             tep_db_perform('orders_total', $orders_total[$key], 'insert');
         }
     }
     return $new_orders_id;
 }
Example #5
0
         </tr>
<?php 
    }
    ?>
          <tr>
            <td class="main"><?php 
    echo OSCOM::getDef('entry_country');
    ?>
</td>
            <td class="main">
<?php 
    if ($error == true) {
        if ($entry_country_error == true) {
            echo HTML::selectField('entry_country_id', tep_get_countries(), $cInfo->entry_country_id) . '&nbsp;' . OSCOM::getDef('entry_country_error');
        } else {
            echo tep_get_country_name($cInfo->entry_country_id) . HTML::hiddenField('entry_country_id');
        }
    } else {
        echo HTML::selectField('entry_country_id', tep_get_countries(), $cInfo->entry_country_id);
    }
    ?>
</td>
          </tr>
        </table></td>
      </tr>
      <tr>
        <td class="formAreaTitle"><?php 
    echo OSCOM::getDef('category_contact');
    ?>
</td>
      </tr>
</td>
             </tr>
<?php 
}
?>
             <tr>
               <td class="main">&nbsp;<?php 
echo ENTRY_COUNTRY;
?>
</td>
               <td class="main">&nbsp;
<?php 
if ($is_read_only) {
    echo tep_get_country_name($address['entry_country_id']);
} else {
    echo tep_draw_input_field('country', tep_get_country_name($address['entry_country_id'])) . '&nbsp; <font color="#FF0000">*</font>';
}
?>

<?php 
tep_draw_hidden_field('step', '3');
?>

</td>
          </tr>
        </table></td>
      </tr>
    </table></td>
  </tr>
  <tr>
    <td class="formAreaTitle"><br><?php 
 $email_table .= Translate('Beste ') . ' ' . Translate('beheerder') . "\n\n";
 $email_table .= "\n" . sprintf(Translate('Een bezoeker heeft zich geregistreerd via %s'), STORE_NAME) . "\n\n";
 $email_table .= '<table cellspacing="0" cellpadding="3" border="0" width="100%">';
 $email_table .= '<tr><td width="150">' . Translate('Voornaam') . ': </td><td>' . $firstname . '</td></tr>';
 $email_table .= "<tr><td>" . Translate('Achternaam') . ': </td><td>' . $lastname . '</td></tr>';
 $email_table .= "<tr><td>" . Translate('E-mailadres') . ': </td><td>' . $email_address . '</td></tr>';
 if (ACCOUNT_COMPANY == 'true') {
     $email_table .= "<tr><td>" . Translate('Bedrijfsnaam') . ': </td><td>' . $company . '</td></tr>';
     $email_table .= "<tr><td>" . Translate('BTW Nummer') . ': </td><td>' . $btwnr . '</td></tr>';
 }
 $email_table .= "<tr><td>" . Translate('Straat en huisnummer') . ': </td><td>' . $street_address . '</td></tr>';
 $email_table .= "<tr><td>" . Translate('Postcode') . ': </td><td>' . $postcode . '</td></tr>';
 $email_table .= "<tr><td>" . Translate('Woonplaats') . ': </td><td>' . $city . '</td></tr>';
 $email_table .= "<tr><td>" . Translate('Telefoonnummer') . ': </td><td>' . $telephone . '</td></tr>';
 $email_table .= "<tr><td>" . Translate('Faxnummer') . ': </td><td>' . $fax . '</td></tr>';
 $email_table .= "<tr><td>" . Translate('Land') . ': </td><td>' . tep_get_country_name($country) . '</td></tr>';
 $email_table .= '</table>';
 $email_table .= "\n\n" . Translate('Zonder manuele toevoeging in het softwarepakket, zal deze klant niet toegelaten worden in het beveiligde gedeelte van de website. ') . "\n\n";
 $email_table .= '</td><td style="width: 5px;"></td></tr></table>';
 $name = $lastname . " " . $firstname;
 $Varlogo = '<a href="' . HTTP_SERVER . DIR_WS_CATALOG . '"><img src="' . HTTP_SERVER . DIR_WS_CATALOG . DIR_WS_IMAGES . 'mail/logo.jpg" border="0" /></a> ';
 $Vartable1 = '<table width="100%"  border="0" cellpadding="0" cellspacing="0" bgcolor="#ffffff">';
 $Vartable2 = '<table width="100%" border="0" cellpadding="3" cellspacing="3" bgcolor="#EFEFEF">';
 $Vartext1 = '<h1>' . Translate('Account aanmaken') . '</h1>';
 $Vartext2 = $email_table;
 //content
 $Varcopyright = Translate('Copyright &copy; 2010');
 $Varmailfooter = Translate('Dit email adres is ingegeven op onze website door u of door een van onze bezoekers. Als u zich niet ingeschreven hebt op onze website contacteer ons dan via') . ' <a href="mailto:' . STORE_OWNER_EMAIL_ADDRESS . '">' . STORE_OWNER_EMAIL_ADDRESS . '</a>';
 require DIR_WS_MODULES . 'email/html_create_account.php';
 $email_text = $html_email_text;
 //END SEND HTML EMAIL//
            <td class="main" width="150">&nbsp;<?php 
echo ENTRY_COUNTRY;
?>
<div id="indicator"><?php 
echo tep_image(DIR_WS_ICONS . 'ajax-loader.gif');
?>
</div></td>
	    <td class="main">
	    <?php 
if ($is_read_only == true) {
    echo tep_get_country_name($affiliate['affiliate_country_id']);
} elseif ($error == true) {
    if ($entry_country_error == true) {
        echo tep_get_country_list('a_country') . '&nbsp;' . ENTRY_COUNTRY_ERROR;
    } else {
        echo tep_get_country_name($a_country) . tep_draw_hidden_field('a_country');
    }
} else {
    // +Country-State Selector
    echo tep_get_country_list('country', $entry['entry_country_id'], 'onChange="getStates(this.value,\'states\');"') . '&nbsp;' . (tep_not_null(ENTRY_COUNTRY_TEXT) ? '<span class="inputRequirement">' . ENTRY_COUNTRY_TEXT . '</span>' : '');
    // -Country-State Selector
}
?>


          </tr>
        </table></td>
      </tr>
    </table></td>
  </tr>
  <tr>
Example #9
0
 public function create_customer($data)
 {
     global $user, $auth, $cart, $customer_id, $currencies;
     $errors = array();
     $process = true;
     $error = false;
     //Gender
     if ($this->options['customers_gender'] == 'on') {
         if (isset($data['gender'])) {
             $gender = mysql_real_escape_string($data['gender']);
         } else {
             $gender = false;
         }
     }
     //Name
     if (isset($data['firstname']) || isset($data['lastname'])) {
         $name = '';
         if ($this->options['customers_firstname'] == 'on') {
             $name .= $data['firstname'];
         }
         if ($this->options['customers_firstname'] == 'on' && $this->options['customers_lastname'] == 'on') {
             $name .= ' ';
         }
         if ($this->options['customers_lastname'] == 'on') {
             $name .= $data['lastname'];
         }
     } else {
         if ($data['name']) {
             $name = $data['name'];
         } else {
             if ($data['fullname']) {
                 $name = $data['fullname'];
             }
         }
     }
     if (strlen($name) < ENTRY_FIRST_NAME_MIN_LENGTH) {
         $error = true;
         $errors['name'] = sprintf(Translate('Uw voornaam moet minstens %s karakters bevatten'), ENTRY_FIRST_NAME_MIN_LENGTH);
     }
     //Day of birth
     if ($this->options['customers_dob'] == 'on') {
         $dob = mysql_real_escape_string($data['dob']);
     }
     //Email adress
     if ($this->options['customers_email_address'] == 'on') {
         $email_address = mysql_real_escape_string($data['email_address']);
         if (tep_validate_email($email_address) == false) {
             $error = true;
             $errors['email_address'] = Translate('Gelieve een geldig e-mailadres in te geven');
         } else {
             $check_email_query = tep_db_query("select count(*) as total from " . TABLE_CUSTOMERS . " where customers_email_address = '" . tep_db_input($email_address) . "'");
             $check_email = tep_db_fetch_array($check_email_query);
             if ($check_email['total'] > 0) {
                 $error = true;
                 $errors['email_address_exists'] = Translate('Het ingegeven e-mailadres bestaat al in ons systeem. Gelieve in te loggen of een account te registreren met een ander e-mailadres');
             }
         }
     }
     //Company
     if ($this->options['entry_company'] == 'on') {
         $company = mysql_real_escape_string($data['company']);
     }
     //BTW nummer
     if ($this->options['billing_tva_intracom'] == 'on') {
         $btwnr = mysql_real_escape_string($data['btwnr']);
     }
     //Forum
     if (FORUM_ACTIVE == 'true' && FORUM_SYNC_USERS == 'true') {
         if (!isset($data['forum_username'])) {
             $data['forum_username'] = $name;
         }
         $forum_username = mysql_real_escape_string($data['forum_username']);
         if (strlen($forum_username) < ENTRY_FORUM_USERNAME_MIN_LENGTH) {
             $error = true;
             $errors['forum_username'] = sprintf(Translate('Uw gebruikersnaam moet minstens %s karakters bevatten'), ENTRY_FORUM_USERNAME_MIN_LENGTH);
         }
         /*check username*/
         $check_username_query = tep_db_query("SELECT user_id FROM " . FORUM_DB_DATABASE . ".users WHERE username_clean = '" . strtolower($forum_username) . "'");
         $check_username = tep_db_fetch_array($check_username_query);
         if (tep_db_num_rows($check_username_query) > 0) {
             $error = true;
             $errors['forum_username_exists'] = Translate('Deze gebruikernaam voor het forum is reeds in gebruik.');
         }
         /*check username*/
         $check_email_query = tep_db_query("SELECT user_id FROM " . FORUM_DB_DATABASE . ".users WHERE user_email = '" . strtolower($email_address) . "'");
         $check_email = tep_db_fetch_array($check_email_query);
         if (tep_db_num_rows($check_email_query) > 0) {
             $error = true;
             $errors['email_address_exists'] = Translate('Het ingegeven e-mailadres bestaat al in ons systeem. Gelieve in te loggen of een account te registreren met een ander e-mailadres');
         }
     }
     //Street address
     if ($this->options['entry_street_address'] == 'on') {
         $street_address = mysql_real_escape_string($data['street_address']);
         if (!preg_match("/[a-zA-Z]\\s\\d/", $street_address)) {
             $error = true;
             $errors['street_address'] = Translate('Gelieve uw straat EN huisnummer in te geven.');
         }
     }
     //Suburb
     if ($this->options['entry_suburb'] == 'on') {
         $suburb = mysql_real_escape_string($data['suburb']);
     }
     //Postcode
     if ($this->options['entry_postcode'] == 'on') {
         $postcode = mysql_real_escape_string($data['postcode']);
         if (strlen($postcode) < ENTRY_POSTCODE_MIN_LENGTH) {
             $error = true;
             $errors['postcode'] = sprintf(Translate('Uw postcode moet minstens %s karakters bevatten'), ENTRY_POSTCODE_MIN_LENGTH);
         }
     }
     //City
     if ($this->options['entry_city'] == 'on') {
         $city = mysql_real_escape_string($data['city']);
         if (strlen($city) < ENTRY_CITY_MIN_LENGTH) {
             $error = true;
             $errors['city'] = sprintf(Translate('Uw woonplaats moet minstens %s karakters bevatten'), ENTRY_CITY_MIN_LENGTH);
         }
     }
     //State
     if ($this->options['entry_state'] == 'on') {
         $state = mysql_real_escape_string($data['state']);
     }
     //Zone
     if ($this->options['entry_zone'] == 'on' && isset($data['zone_id'])) {
         $zone_id = mysql_real_escape_string($data['zone_id']);
     } else {
         $zone_id = false;
     }
     //Country
     if ($this->options['entry_country'] == 'on') {
         $country = mysql_real_escape_string($data['country']);
         if (is_numeric($country) == false || $country == '0') {
             $error = true;
             $errors['country'] = Translate('Gelieve een land uit de lijst te selecteren');
         }
     }
     //Telephone
     if ($this->options['customers_telephone'] == 'on') {
         $telephone = mysql_real_escape_string($data['telephone']);
         if (strlen($telephone) < 5) {
             $error = true;
             $errors['telephone'] = Translate('Gelieve op een correcte manier uw telefoonnummer in te geven.');
         }
     }
     //Fax
     if ($this->options['customers_fax'] == 'on') {
         $fax = mysql_real_escape_string($data['fax']);
         if ($fax != '') {
             if (strlen($fax) < 5) {
                 $error = true;
                 $errors['fax'] = Translate('Gelieve op de correcte manier uw faxnummer in te geven.');
             }
         }
     }
     //Create account type
     if ($this->options['create_account_mode'] == 'Direct access' || $this->options['create_account_mode'] == 'Moderated access') {
         $password = mysql_real_escape_string($data['password']);
         $confirmation = mysql_real_escape_string($data['confirmation']);
         if (strlen($password) < ENTRY_PASSWORD_MIN_LENGTH) {
             $error = true;
             $errors['password'] = sprintf(Translate('Uw paswoord moet minstens %s karakters bevatten'), ENTRY_PASSWORD_MIN_LENGTH);
         } elseif ($password != $confirmation) {
             $error = true;
             $errors['confirmation'] = Translate('De ingevoerde wachtwoorden moeten hetzelfde zijn. Voer ze opnieuw in.');
         }
     }
     if ($this->options['conditions_create_account'] != 'Uitgeschakeld' && CONDITIONS_MUST_ACCEPT == 'true') {
         $terms = mysql_real_escape_string($data['TermsAgree']);
         if (!$terms) {
             $error = true;
             $errors['terms'] = Translate('U moet akkoord gaan met de algemene voorwaarden voor u een account kan aanmaken!');
         }
     }
     //Check if error
     if ($error) {
         return array('errors' => $errors);
     } else {
         if ($this->options['create_account_mode'] == 'Direct access' || $this->options['create_account_mode'] == 'Moderated access') {
             /********************************/
             /*	Direct Or Moderated access	*/
             /********************************/
             if ($this->options['create_account_mode'] == 'Moderated access') {
                 $status = '0';
             } else {
                 $status = '1';
             }
             //Newsletter
             $lists = PHPLIST_LISTNUMBERS;
             $lists = explode(';', $lists);
             $newsletter = false;
             foreach ($lists as $key => $list) {
                 if (isset($data['newsletters_' . $list])) {
                     put_user_in_list($list, 'subscribe', $email_address, $lastname . ' ' . $firstname);
                     $newsletter = true;
                 }
             }
             //Customers table
             $sql_data_array = array('customers_firstname' => $name, 'customers_lastname' => '', 'customers_email_address' => $email_address, 'customers_telephone' => $telephone, 'customers_fax' => $fax, 'customers_newsletter' => $newsletter, 'customers_password' => tep_encrypt_password($password), 'status' => $status);
             if (ACCOUNT_GENDER == 'true') {
                 $sql_data_array['customers_gender'] = $gender;
             }
             if (ACCOUNT_DOB == 'true') {
                 $sql_data_array['customers_dob'] = tep_date_raw($dob);
             }
             tep_db_perform('customers', $sql_data_array);
             $customer_id = tep_db_insert_id();
             //Address book table
             $sql_data_array = array('customers_id' => $customer_id, 'entry_firstname' => $name, 'entry_lastname' => '', 'entry_street_address' => $street_address, 'entry_postcode' => $postcode, 'entry_city' => $city, 'entry_country_id' => $country);
             if (ACCOUNT_GENDER == 'true') {
                 $sql_data_array['entry_gender'] = $gender;
             }
             if (ACCOUNT_COMPANY == 'true') {
                 $sql_data_array['entry_company'] = $company;
             }
             if (ACCOUNT_COMPANY == 'true') {
                 $sql_data_array['billing_tva_intracom'] = $btwnr;
             }
             if (ACCOUNT_SUBURB == 'true') {
                 $sql_data_array['entry_suburb'] = $suburb;
             }
             if (ACCOUNT_STATE == 'true') {
                 if ($zone_id > 0) {
                     $sql_data_array['entry_zone_id'] = $zone_id;
                     $sql_data_array['entry_state'] = '';
                 } else {
                     $sql_data_array['entry_zone_id'] = '0';
                     $sql_data_array['entry_state'] = $state;
                 }
             }
             tep_db_perform('address_book', $sql_data_array);
             $address_id = tep_db_insert_id();
             tep_db_query("update customers set customers_default_address_id = '" . (int) $address_id . "' where customers_id = '" . (int) $customer_id . "'");
             //Customers info table
             tep_db_query("insert into customers_info (customers_info_id, customers_info_number_of_logons, customers_info_date_account_created) values ('" . (int) $customer_id . "', '0', now())");
             //Session
             if (SESSION_RECREATE == 'True') {
                 tep_session_recreate();
             }
             $customer_first_name = $name;
             $customer_default_address_id = $address_id;
             $customer_country_id = $country;
             $customer_zone_id = $zone_id;
             if ($this->options['create_account_mode'] == 'Direct access') {
                 /********************/
                 /*	Direct access	*/
                 /********************/
                 //Forum
                 if (FORUM_ACTIVE == 'true' && FORUM_SYNC_USERS == 'true' && !empty($forum_username)) {
                     /*add user*/
                     $sql_data_array = array('user_type' => '0', 'group_id' => '10', 'user_permissions' => '', 'user_ip' => $_SERVER['REMOTE_ADDR'], 'user_regdate' => time(), 'username' => $forum_username, 'username_clean' => strtolower($forum_username), 'user_password' => phpbb_hash($password), 'user_passchg' => time(), 'user_email' => strtolower($email_address), 'user_email_hash' => phpbb_email_hash(strtolower($email_address)), 'user_lastvisit' => time(), 'user_lastmark' => time(), 'user_lastpage' => FILENAME_CREATE_ACCOUNT, 'user_lang' => 'nl', 'user_timezone' => '1.00', 'user_dst' => '1', 'user_dateformat' => 'd M Y, H:i', 'user_style' => '3', 'user_form_salt' => unique_id(), 'user_new' => '1');
                     tep_db_perform(FORUM_DB_DATABASE . '.users', $sql_data_array, 'insert', false);
                     /*get user id*/
                     $get_forum_user_query = tep_db_query("SELECT user_id FROM " . FORUM_DB_DATABASE . ".users WHERE user_email = '" . $email_address . "'");
                     $get_forum_user = tep_db_fetch_array($get_forum_user_query);
                     $get_usergroup_query = tep_db_query("SELECT group_id FROM " . FORUM_DB_DATABASE . ".groups WHERE group_name = 'REGISTERED'");
                     $get_usergroup = tep_db_fetch_array($get_usergroup_query);
                     /*add user to groups*/
                     tep_db_query("INSERT INTO " . FORUM_DB_DATABASE . ".user_group (group_id, user_id, group_leader, user_pending) VALUES ('" . $get_usergroup['group_id'] . "','" . $get_forum_user['user_id'] . "','0','0')");
                     /*user is created, let's add session for autologin*/
                     if (FORUM_CROSS_LOGIN == 'true') {
                         $user->session_begin();
                         $auth->acl($user->data);
                         $auth->login(strtolower($forum_username), $password, false, 1, 0);
                     }
                 }
                 //Session
                 $_SESSION['customer_id'] = $customer_id;
                 $_SESSION['customer_first_name'] = $customer_first_name;
                 $_SESSION['customer_default_address_id'] = $customer_default_address_id;
                 $_SESSION['customer_country_id'] = $customer_country_id;
                 $_SESSION['customer_zone_id'] = $customer_zone_id;
                 // restore cart contents
                 $cart->restore_contents();
                 //HTML mail
                 $email_table = '<table cellspacing="0" cellpadding="0" border="0" width="587" bgcolor="#ffffff">';
                 $email_table .= '<tr><td style="width:5px;"></td><td>';
                 $email_table .= Translate('Beste ') . '&nbsp;' . $name . "\n\n";
                 $email_table .= "\n" . sprintf(Translate('Wij heten u welkom bij <b>%s</b>'), STORE_NAME) . "\n\n";
                 $email_table .= "\n" . Translate('U kunt nu gebruik maken van <b>verschillende services</b> die wij aanbieden. Enkele van deze services zijn:' . "\n\n" . '<li><b>Permanente Winkelwagen</b> - Elk product die u hierin plaatst zal daar blijven totdat u ze zelf verwijderd, of gaat afrekenen.' . "\n" . '<li><b>Bestel Geschiedenis</b> - Bekijk de bestellingen die u eerder heeft geplaatst.' . "\n\n");
                 //Cadeaubon voor nieuwe klanten
                 if (NEW_SIGNUP_GIFT_VOUCHER_AMOUNT > 0) {
                     $coupon_code = create_coupon_code();
                     $insert_query = tep_db_query("insert into coupons (coupon_code, coupon_type, coupon_amount, date_created) values ('" . $coupon_code . "', 'G', '" . NEW_SIGNUP_GIFT_VOUCHER_AMOUNT . "', now())");
                     $insert_id = tep_db_insert_id();
                     $insert_query = tep_db_query("insert into coupon_email_track (coupon_id, customer_id_sent, sent_firstname, emailed_to, date_sent) values ('" . $insert_id . "', '0', 'Admin', '" . $email_address . "', now() )");
                     $email_table .= sprintf(Translate('Als deel van de verwelkoming van nieuwe klanten hebben wij u een cadeaubon verstuurd ter waarde van %s'), $currencies->format(NEW_SIGNUP_GIFT_VOUCHER_AMOUNT)) . "\n\n";
                     $email_table .= Translate('U kan de cadeaubon valideren door op deze link te klikken') . ' <a href="' . tep_href_link(FILENAME_GV_REDEEM, 'gift=' . $coupon_code, 'NONSSL', false) . '">' . tep_href_link(FILENAME_GV_REDEEM, 'gift=' . $coupon_code, 'NONSSL', false) . '</a>' . "\n\n";
                 }
                 //Coupon code voor nieuwe klanten
                 if (NEW_SIGNUP_DISCOUNT_COUPON != '') {
                     $coupon_code = NEW_SIGNUP_DISCOUNT_COUPON;
                     $coupon_query = tep_db_query("select * from coupons where coupon_code = '" . $coupon_code . "'");
                     $coupon = tep_db_fetch_array($coupon_query);
                     $coupon_id = $coupon['coupon_id'];
                     $coupon_desc_query = tep_db_query("select * from coupons_description where coupon_id = '" . $coupon_id . "' and language_id = '" . (int) $languages_id . "'");
                     $coupon_desc = tep_db_fetch_array($coupon_desc_query);
                     $insert_query = tep_db_query("insert into coupon_email_track (coupon_id, customer_id_sent, sent_firstname, emailed_to, date_sent) values ('" . $coupon_id . "', '0', 'Admin', '" . $email_address . "', now() )");
                     $email_table .= Translate('Proficiat, om uw eerste bezoek aan onze shop aangenamer te maken zenden wij u een kortings coupon.') . "\n";
                     $email_table .= sprintf(Translate('Om de coupon te gebruiken vult u de coupon code, %s, in tijdens de checkout.'), $coupon['coupon_code']) . "\n\n";
                 }
                 $email_table .= "\n" . Translate('Voor hulp met een van deze services kunt u een email sturen naar ' . STORE_NAME . ': ' . STORE_OWNER_EMAIL_ADDRESS . '.' . "\n\n");
                 $email_table .= '</td><td style="width: 5px;"></td></tr></table>';
                 $Varlogo = '<a href="' . HTTP_SERVER . DIR_WS_CATALOG . '"><img src="' . HTTP_SERVER . DIR_WS_CATALOG . DIR_WS_IMAGES . 'mail/logo.jpg" border="0" /></a> ';
                 $Vartable1 = '<table width="100%"  border="0" cellpadding="0" cellspacing="0" bgcolor="#ffffff">';
                 $Vartable2 = '<table width="100%" border="0" cellpadding="3" cellspacing="3" bgcolor="#EFEFEF">';
                 $Vartext1 = '<h1>' . Translate('Account aanmaken') . '</h1>';
                 $Vartext2 = $email_table;
                 //content
                 $Varcopyright = 'Copyright &copy; ' . date('Y');
                 $Varmailfooter = Translate('Dit email adres is ingegeven op onze website door u of door een van onze bezoekers. Als u zich niet ingeschreven hebt op onze website contacteer ons dan via') . ' <a href="mailto:' . STORE_OWNER_EMAIL_ADDRESS . '">' . STORE_OWNER_EMAIL_ADDRESS . '</a>';
                 require DIR_WS_MODULES . 'email/html_create_account.php';
                 $email_text = $html_email_text;
                 //Send mail
                 tep_mail($name, $email_address, sprintf(Translate('Welkom bij %s'), STORE_NAME), $email_text, STORE_OWNER, STORE_OWNER_EMAIL_ADDRESS);
             } else {
                 /************************/
                 /*	Moderated access	*/
                 /************************/
                 //Mail to store owner
                 $email_table = '<table cellspacing="0" cellpadding="0" border="0" width="587" bgcolor="#ffffff">';
                 $email_table .= '<tr><td style="width:5px;"></td><td>';
                 $email_table .= Translate('Beste ') . ' ' . Translate('beheerder') . "\n\n";
                 $email_table .= "\n" . sprintf(Translate('Een bezoeker heeft zich geregistreerd via %s'), STORE_NAME) . "\n\n";
                 $email_table .= "\n\n" . Translate('Deze klant zal pas kunnen inloggen op het beveiligd gedeelte van de website, nadat u de account activeert door middel van onderstaande link.') . "\n\n";
                 $email_table .= "\n\n" . '<a href="' . HTTP_SERVER . DIR_WS_HTTP_CATALOG . 'scripts/user_activate.php?user='******'">' . Translate('account activeren') . "</a>" . "\n\n";
                 $email_table .= '<table cellspacing="0" cellpadding="3" border="0" width="100%">';
                 $email_table .= '<tr><td width="150">' . Translate('Naam') . ': </td><td>' . $name . '</td></tr>';
                 //Email
                 if ($this->options['customers_email_address'] == 'on') {
                     $email_table .= "<tr><td>" . Translate('E-mailadres') . ': </td><td>' . $email_address . '</td></tr>';
                 }
                 //Company
                 if ($this->options['entry_company'] == 'on') {
                     $email_table .= "<tr><td>" . Translate('Bedrijfsnaam') . ': </td><td>' . $company . '</td></tr>';
                 }
                 //BTW nummer
                 if ($this->options['billing_tva_intracom'] == 'on') {
                     $email_table .= "<tr><td>" . Translate('BTW Nummer') . ': </td><td>' . $btwnr . '</td></tr>';
                 }
                 //Street address
                 if ($this->options['entry_street_address'] == 'on') {
                     $email_table .= "<tr><td>" . Translate('Straat en huisnummer') . ': </td><td>' . $street_address . '</td></tr>';
                 }
                 //Postcode
                 if ($this->options['entry_postcode'] == 'on') {
                     $email_table .= "<tr><td>" . Translate('Postcode') . ': </td><td>' . $postcode . '</td></tr>';
                 }
                 //City
                 if ($this->options['entry_city'] == 'on') {
                     $email_table .= "<tr><td>" . Translate('Woonplaats') . ': </td><td>' . $city . '</td></tr>';
                 }
                 //Telephone
                 if ($this->options['customers_telephone'] == 'on') {
                     $email_table .= "<tr><td>" . Translate('Telefoonnummer') . ': </td><td>' . $telephone . '</td></tr>';
                 }
                 //Fax
                 if ($this->options['customers_fax'] == 'on') {
                     $email_table .= "<tr><td>" . Translate('Faxnummer') . ': </td><td>' . $fax . '</td></tr>';
                 }
                 //Country
                 if ($this->options['entry_country'] == 'on') {
                     $email_table .= "<tr><td>" . Translate('Land') . ': </td><td>' . tep_get_country_name($country) . '</td></tr>';
                 }
                 $email_table .= '</table>';
                 $email_table .= '</td><td style="width: 5px;"></td></tr></table>';
                 $Varlogo = '<a href="' . HTTP_SERVER . DIR_WS_CATALOG . '"><img src="' . HTTP_SERVER . DIR_WS_CATALOG . DIR_WS_IMAGES . 'mail/logo.jpg" border="0" /></a> ';
                 $Vartable1 = '<table width="100%"  border="0" cellpadding="0" cellspacing="0" bgcolor="#ffffff">';
                 $Vartable2 = '<table width="100%" border="0" cellpadding="3" cellspacing="3" bgcolor="#EFEFEF">';
                 $Vartext1 = '<h1>' . Translate('Account aanmaken') . '</h1>';
                 $Vartext2 = $email_table;
                 //content
                 $Varcopyright = Translate('Copyright &copy; 2010');
                 $Varmailfooter = Translate('Dit email adres is ingegeven op onze website door u of door een van onze bezoekers. Als u zich niet ingeschreven hebt op onze website contacteer ons dan via') . ' <a href="mailto:' . STORE_OWNER_EMAIL_ADDRESS . '">' . STORE_OWNER_EMAIL_ADDRESS . '</a>';
                 require DIR_WS_MODULES . 'email/html_create_account.php';
                 $email_text = $html_email_text;
                 tep_mail(STORE_OWNER, STORE_OWNER_EMAIL_ADDRESS, Translate('Nieuwe registratie'), $email_text, $name, $email_address);
                 //Mail to customer
                 $email_table = '<table cellspacing="0" cellpadding="0" border="0" width="587" bgcolor="#ffffff">';
                 $email_table .= '<tr><td style="width:5px;"></td><td>';
                 $email_table .= Translate('Beste ') . ' ' . $name . "\n\n";
                 $email_table .= "\n\n" . Translate('Uw account voor onze website werd succesvol aangevraagd. Hieronder vind u nog eens de ingevulde gegevens. Uw gegevens zijn aan ons doorgegeven voor moderatie. Van zodra uw account geactiveerd is, ontvangt u hierover een e-mail.') . "\n\n";
                 $email_table .= '<table cellspacing="0" cellpadding="3" border="0" width="100%">';
                 $email_table .= '<tr><td width="150">' . Translate('Naam') . ': </td><td>' . $name . '</td></tr>';
                 //Email
                 if ($this->options['customers_email_address'] == 'on') {
                     $email_table .= "<tr><td>" . Translate('E-mailadres') . ': </td><td>' . $email_address . '</td></tr>';
                 }
                 //Company
                 if ($this->options['entry_company'] == 'on') {
                     $email_table .= "<tr><td>" . Translate('Bedrijfsnaam') . ': </td><td>' . $company . '</td></tr>';
                 }
                 //BTW nummer
                 if ($this->options['billing_tva_intracom'] == 'on') {
                     $email_table .= "<tr><td>" . Translate('BTW Nummer') . ': </td><td>' . $btwnr . '</td></tr>';
                 }
                 //Street address
                 if ($this->options['entry_street_address'] == 'on') {
                     $email_table .= "<tr><td>" . Translate('Straat en huisnummer') . ': </td><td>' . $street_address . '</td></tr>';
                 }
                 //Postcode
                 if ($this->options['entry_postcode'] == 'on') {
                     $email_table .= "<tr><td>" . Translate('Postcode') . ': </td><td>' . $postcode . '</td></tr>';
                 }
                 //City
                 if ($this->options['entry_city'] == 'on') {
                     $email_table .= "<tr><td>" . Translate('Woonplaats') . ': </td><td>' . $city . '</td></tr>';
                 }
                 //Telephone
                 if ($this->options['customers_telephone'] == 'on') {
                     $email_table .= "<tr><td>" . Translate('Telefoonnummer') . ': </td><td>' . $telephone . '</td></tr>';
                 }
                 //Fax
                 if ($this->options['customers_fax'] == 'on') {
                     $email_table .= "<tr><td>" . Translate('Faxnummer') . ': </td><td>' . $fax . '</td></tr>';
                 }
                 //Country
                 if ($this->options['entry_country'] == 'on') {
                     $email_table .= "<tr><td>" . Translate('Land') . ': </td><td>' . tep_get_country_name($country) . '</td></tr>';
                 }
                 $email_table .= '</table>';
                 $email_table .= '</td><td style="width: 5px;"></td></tr></table>';
                 $Varlogo = '<a href="' . HTTP_SERVER . DIR_WS_CATALOG . '"><img src="' . HTTP_SERVER . DIR_WS_CATALOG . DIR_WS_IMAGES . 'mail/logo.jpg" border="0" /></a> ';
                 $Vartable1 = '<table width="100%"  border="0" cellpadding="0" cellspacing="0" bgcolor="#ffffff">';
                 $Vartable2 = '<table width="100%" border="0" cellpadding="3" cellspacing="3" bgcolor="#EFEFEF">';
                 $Vartext1 = '<h1>' . Translate('Account aanmaken') . '</h1>';
                 $Vartext2 = $email_table;
                 //content
                 $Varcopyright = Translate('Copyright &copy; 2010');
                 $Varmailfooter = Translate('Dit email adres is ingegeven op onze website door u of door een van onze bezoekers. Als u zich niet ingeschreven hebt op onze website contacteer ons dan via') . ' <a href="mailto:' . STORE_OWNER_EMAIL_ADDRESS . '">' . STORE_OWNER_EMAIL_ADDRESS . '</a>';
                 require DIR_WS_MODULES . 'email/html_create_account.php';
                 $email_text = $html_email_text;
                 tep_mail($name, $email_address, Translate('Nieuwe registratie'), $email_text, STORE_OWNER, STORE_OWNER_EMAIL_ADDRESS);
             }
         } else {
             /********************/
             /*	Request account	*/
             /********************/
             $email_table = '<table cellspacing="0" cellpadding="0" border="0" width="587" bgcolor="#ffffff">';
             $email_table .= '<tr><td style="width:5px;"></td><td>';
             $email_table .= Translate('Beste ') . ' ' . Translate('beheerder') . "\n\n";
             $email_table .= "\n" . sprintf(Translate('Een bezoeker heeft zich geregistreerd via %s'), STORE_NAME) . "\n\n";
             $email_table .= '<table cellspacing="0" cellpadding="3" border="0" width="100%">';
             $email_table .= '<tr><td width="150">' . Translate('Naam') . ': </td><td>' . $name . '</td></tr>';
             //Email
             if ($this->options['customers_email_address'] == 'on') {
                 $email_table .= "<tr><td>" . Translate('E-mailadres') . ': </td><td>' . $email_address . '</td></tr>';
             }
             //Company
             if ($this->options['entry_company'] == 'on') {
                 $email_table .= "<tr><td>" . Translate('Bedrijfsnaam') . ': </td><td>' . $company . '</td></tr>';
             }
             //BTW nummer
             if ($this->options['billing_tva_intracom'] == 'on') {
                 $email_table .= "<tr><td>" . Translate('BTW Nummer') . ': </td><td>' . $btwnr . '</td></tr>';
             }
             //Street address
             if ($this->options['entry_street_address'] == 'on') {
                 $email_table .= "<tr><td>" . Translate('Straat en huisnummer') . ': </td><td>' . $street_address . '</td></tr>';
             }
             //Postcode
             if ($this->options['entry_postcode'] == 'on') {
                 $email_table .= "<tr><td>" . Translate('Postcode') . ': </td><td>' . $postcode . '</td></tr>';
             }
             //City
             if ($this->options['entry_city'] == 'on') {
                 $email_table .= "<tr><td>" . Translate('Woonplaats') . ': </td><td>' . $city . '</td></tr>';
             }
             //Telephone
             if ($this->options['customers_telephone'] == 'on') {
                 $email_table .= "<tr><td>" . Translate('Telefoonnummer') . ': </td><td>' . $telephone . '</td></tr>';
             }
             //Fax
             if ($this->options['customers_fax'] == 'on') {
                 $email_table .= "<tr><td>" . Translate('Faxnummer') . ': </td><td>' . $fax . '</td></tr>';
             }
             //Country
             if ($this->options['entry_country'] == 'on') {
                 $email_table .= "<tr><td>" . Translate('Land') . ': </td><td>' . tep_get_country_name($country) . '</td></tr>';
             }
             $email_table .= '</table>';
             $email_table .= "\n\n" . Translate('Zonder manuele toevoeging in het softwarepakket, zal deze klant niet toegelaten worden in het beveiligde gedeelte van de website. ') . "\n\n";
             $email_table .= '</td><td style="width: 5px;"></td></tr></table>';
             $Varlogo = '<a href="' . HTTP_SERVER . DIR_WS_CATALOG . '"><img src="' . HTTP_SERVER . DIR_WS_CATALOG . DIR_WS_IMAGES . 'mail/logo.jpg" border="0" /></a> ';
             $Vartable1 = '<table width="100%"  border="0" cellpadding="0" cellspacing="0" bgcolor="#ffffff">';
             $Vartable2 = '<table width="100%" border="0" cellpadding="3" cellspacing="3" bgcolor="#EFEFEF">';
             $Vartext1 = '<h1>' . Translate('Account aanmaken') . '</h1>';
             $Vartext2 = $email_table;
             //content
             $Varcopyright = Translate('Copyright &copy; 2010');
             $Varmailfooter = Translate('Dit email adres is ingegeven op onze website door u of door een van onze bezoekers. Als u zich niet ingeschreven hebt op onze website contacteer ons dan via') . ' <a href="mailto:' . STORE_OWNER_EMAIL_ADDRESS . '">' . STORE_OWNER_EMAIL_ADDRESS . '</a>';
             require DIR_WS_MODULES . 'email/html_create_account.php';
             $email_text = $html_email_text;
             tep_mail(STORE_OWNER, STORE_OWNER_EMAIL_ADDRESS, Translate('Nieuwe registratie'), $email_text, $name, $email_address);
         }
         return array('address_book_id' => $address_id, 'customer_id' => $customer_id);
     }
 }
Example #10
0
function tep_address_format($address_format_id, $address, $html, $boln, $eoln)
{
    $address_format_query = tep_db_query("select address_format as format from " . TABLE_ADDRESS_FORMAT . " where address_format_id = '" . (int) $address_format_id . "'");
    $address_format = tep_db_fetch_array($address_format_query);
    $company = tep_output_string_protected($address['company']);
    if (isset($address['firstname']) && tep_not_null($address['firstname'])) {
        $firstname = tep_output_string_protected($address['firstname']);
        $lastname = tep_output_string_protected($address['lastname']);
    } elseif (isset($address['name']) && tep_not_null($address['name'])) {
        $firstname = tep_output_string_protected($address['name']);
        $lastname = '';
    } else {
        $firstname = '';
        $lastname = '';
    }
    $street = tep_html_entity_decode(tep_output_string_protected($address['street_address']));
    $suburb = tep_html_entity_decode(tep_output_string_protected($address['suburb']));
    $city = tep_html_entity_decode(tep_output_string_protected($address['city']));
    $state = tep_html_entity_decode(tep_output_string_protected($address['state']));
    $telephone = tep_html_entity_decode($address['telephone']);
    if (isset($address['country_id']) && tep_not_null($address['country_id'])) {
        $country = tep_get_country_name($address['country_id']);
        if (isset($address['zone_id']) && tep_not_null($address['zone_id'])) {
            //		$state = tep_get_zone_code($address['country_id'], $address['zone_id'], $state);
            $state = tep_get_zone_name($address['country_id'], $address['zone_id'], $state);
        }
    } elseif (isset($address['country']) && tep_not_null($address['country'])) {
        $country = tep_output_string_protected($address['country']);
    } else {
        $country = '';
    }
    if ($state == $city) {
        $city = '';
    }
    if (tep_not_null($address['postcode'])) {
        $postcode = tep_output_string_protected($address['postcode']) . ', ';
        $zip = $postcode;
    }
    if ($html) {
        // HTML Mode
        $HR = '<hr size="1" />';
        $hr = '<hr size="1" />';
        if ($boln == '' && $eoln == "\n") {
            // Values not specified, use rational defaults
            $CR = '<br />';
            $cr = '<br />';
            $eoln = $cr;
        } else {
            // Use values supplied
            $CR = $eoln . $boln;
            $cr = $CR;
        }
    } else {
        // Text Mode
        $CR = $eoln;
        $cr = $CR;
        $HR = '----------------------------------------';
        $hr = '----------------------------------------';
    }
    $statecomma = '';
    $streets = $street;
    //    if ($suburb != '') $state .= $street . $cr . $suburb;
    if ($country == '') {
        $country = tep_output_string_protected($address['country']);
    }
    if ($state != '' && $state != $city) {
        $statecomma = $state . ', ';
    }
    $fmt = $address_format['format'];
    eval("\$address = \"{$fmt}\";");
    if (ACCOUNT_COMPANY == 'true' && tep_not_null($company)) {
        $address = $company . $cr . $address;
    }
    while (substr(trim($address), 0, 1) == ',') {
        $address = substr(trim($address), 1);
    }
    while (preg_match('/,\\s?,/', $address)) {
        $address = preg_replace('/,\\s?,/', ',', $address);
    }
    while (strpos($address, ' ,') !== false) {
        $address = str_replace(' ,', ',', $address);
    }
    if (substr(trim($address), -1) == ',') {
        $address = substr(trim($address), 0, -1);
    }
    return trim($address);
}
Example #11
0
function tep_address_format($address_format_id, $address, $html, $boln, $eoln)
{
    $OSCOM_Db = Registry::get('Db');
    $Qformat = $OSCOM_Db->prepare('select address_format from :table_address_format where address_format_id = :address_format_id');
    $Qformat->bindInt(':address_format_id', $address_format_id);
    $Qformat->execute();
    $replace = ['$company' => HTML::outputProtected($address['company']), '$firstname' => '', '$lastname' => '', '$street' => HTML::outputProtected($address['street_address']), '$suburb' => HTML::outputProtected($address['suburb']), '$city' => HTML::outputProtected($address['city']), '$state' => HTML::outputProtected($address['state']), '$postcode' => HTML::outputProtected($address['postcode']), '$country' => ''];
    if (isset($address['firstname']) && tep_not_null($address['firstname'])) {
        $replace['$firstname'] = HTML::outputProtected($address['firstname']);
        $replace['$lastname'] = HTML::outputProtected($address['lastname']);
    } elseif (isset($address['name']) && tep_not_null($address['name'])) {
        $replace['$firstname'] = HTML::outputProtected($address['name']);
    }
    if (isset($address['country_id']) && tep_not_null($address['country_id'])) {
        $replace['$country'] = tep_get_country_name($address['country_id']);
        if (isset($address['zone_id']) && tep_not_null($address['zone_id'])) {
            $replace['$state'] = tep_get_zone_code($address['country_id'], $address['zone_id'], $replace['$state']);
        }
    } elseif (isset($address['country']) && tep_not_null($address['country'])) {
        $replace['$country'] = HTML::outputProtected($address['country']['title']);
    }
    $replace['$zip'] = $replace['$postcode'];
    if ($html) {
        // HTML Mode
        $HR = '<hr />';
        $hr = '<hr />';
        if ($boln == '' && $eoln == "\n") {
            // Values not specified, use rational defaults
            $CR = '<br />';
            $cr = '<br />';
            $eoln = $cr;
        } else {
            // Use values supplied
            $CR = $eoln . $boln;
            $cr = $CR;
        }
    } else {
        // Text Mode
        $CR = $eoln;
        $cr = $CR;
        $HR = '----------------------------------------';
        $hr = '----------------------------------------';
    }
    $replace['$CR'] = $CR;
    $replace['$cr'] = $cr;
    $replace['$HR'] = $HR;
    $replace['$hr'] = $hr;
    $replace['$statecomma'] = '';
    $replace['$streets'] = $replace['$street'];
    if ($replace['$suburb'] != '') {
        $replace['$streets'] = $replace['$street'] . $replace['$cr'] . $replace['$suburb'];
    }
    if ($replace['$state'] != '') {
        $replace['$statecomma'] = $replace['$state'] . ', ';
    }
    $address = strtr($Qformat->value('address_format'), $replace);
    if (ACCOUNT_COMPANY == 'true' && tep_not_null($replace['$company'])) {
        $address = $replace['$company'] . $replace['$cr'] . $address;
    }
    return $address;
}
Example #12
0
     $_SESSION['billing_same_as_customer'] = $_POST['billing_same_as_customer'];
 }
 if (isset($_POST['shipping_same_as_billing'])) {
     $_SESSION['shipping_same_as_billing'] = $_POST['shipping_same_as_billing'];
 }
 // Update Order Info
 //figure out the new currency value
 $currency_value_query = tep_db_query("SELECT value \n                                              FROM " . TABLE_CURRENCIES . " \n                                              WHERE code = '" . $_POST['update_info_payment_currency'] . "'");
 $currency_value = tep_db_fetch_array($currency_value_query);
 //figure out the country, state
 $update_customer_state = tep_get_zone_name($_POST['update_customer_country_id'], $_POST['update_customer_zone_id'], $_POST['update_customer_state']);
 $update_customer_country = tep_get_country_name($_POST['update_customer_country_id']);
 $update_billing_state = tep_get_zone_name($_POST['update_billing_country_id'], $_POST['update_billing_zone_id'], $_POST['update_billing_state']);
 $update_billing_country = tep_get_country_name($_POST['update_billing_country_id']);
 $update_delivery_state = tep_get_zone_name($_POST['update_delivery_country_id'], $_POST['update_delivery_zone_id'], $_POST['update_delivery_state']);
 $update_delivery_country = tep_get_country_name($_POST['update_delivery_country_id']);
 $sql_data_array = array('customers_name' => tep_db_input(tep_db_prepare_input($_POST['update_customer_name'])), 'customers_company' => tep_db_input(tep_db_prepare_input($_POST['update_customer_company'])), 'customers_street_address' => tep_db_input(tep_db_prepare_input($_POST['update_customer_street_address'])), 'customers_suburb' => tep_db_input(tep_db_prepare_input($_POST['update_customer_suburb'])), 'customers_city' => tep_db_input(tep_db_prepare_input($_POST['update_customer_city'])), 'customers_state' => tep_db_input(tep_db_prepare_input($update_customer_state)), 'customers_postcode' => tep_db_input(tep_db_prepare_input($_POST['update_customer_postcode'])), 'customers_country' => tep_db_input(tep_db_prepare_input($update_customer_country)), 'customers_telephone' => tep_db_input(tep_db_prepare_input($_POST['update_customer_telephone'])), 'customers_email_address' => tep_db_input(tep_db_prepare_input($_POST['update_customer_email_address'])), 'billing_name' => tep_db_input(tep_db_prepare_input(isset($_POST['billing_same_as_customer']) && $_POST['billing_same_as_customer'] == 'on' ? $_POST['update_customer_name'] : $_POST['update_billing_name'])), 'billing_company' => tep_db_input(tep_db_prepare_input(isset($_POST['billing_same_as_customer']) && $_POST['billing_same_as_customer'] == 'on' ? $_POST['update_customer_company'] : $_POST['update_billing_company'])), 'billing_street_address' => tep_db_input(tep_db_prepare_input(isset($_POST['billing_same_as_customer']) && $_POST['billing_same_as_customer'] == 'on' ? $_POST['update_customer_street_address'] : $_POST['update_billing_street_address'])), 'billing_suburb' => tep_db_input(tep_db_prepare_input(isset($_POST['billing_same_as_customer']) && $_POST['billing_same_as_customer'] == 'on' ? $_POST['update_customer_suburb'] : $_POST['update_billing_suburb'])), 'billing_city' => tep_db_input(tep_db_prepare_input(isset($_POST['billing_same_as_customer']) && $_POST['billing_same_as_customer'] == 'on' ? $_POST['update_customer_city'] : $_POST['update_billing_city'])), 'billing_state' => tep_db_input(tep_db_prepare_input(isset($_POST['billing_same_as_customer']) && $_POST['billing_same_as_customer'] == 'on' ? $update_customer_state : $update_billing_state)), 'billing_postcode' => tep_db_input(tep_db_prepare_input(isset($_POST['billing_same_as_customer']) && $_POST['billing_same_as_customer'] == 'on' ? $_POST['update_customer_postcode'] : $_POST['update_billing_postcode'])), 'billing_country' => tep_db_input(tep_db_prepare_input(isset($_POST['billing_same_as_customer']) && $_POST['billing_same_as_customer'] == 'on' ? $update_customer_country : $update_billing_country)), 'delivery_name' => tep_db_input(tep_db_prepare_input(isset($_POST['shipping_same_as_billing']) && $_POST['shipping_same_as_billing'] == 'on' ? $_POST['billing_same_as_customer'] == 'on' ? $_POST['update_customer_name'] : $_POST['update_billing_name'] : $_POST['update_delivery_name'])), 'delivery_company' => tep_db_input(tep_db_prepare_input(isset($_POST['shipping_same_as_billing']) && $_POST['shipping_same_as_billing'] == 'on' ? $_POST['billing_same_as_customer'] == 'on' ? $_POST['update_customer_company'] : $_POST['update_billing_company'] : $_POST['update_delivery_company'])), 'delivery_street_address' => tep_db_input(tep_db_prepare_input(isset($_POST['shipping_same_as_billing']) && $_POST['shipping_same_as_billing'] == 'on' ? $_POST['billing_same_as_customer'] == 'on' ? $_POST['update_customer_street_address'] : $_POST['update_billing_street_address'] : $_POST['update_delivery_street_address'])), 'delivery_suburb' => tep_db_input(tep_db_prepare_input(isset($_POST['shipping_same_as_billing']) && $_POST['shipping_same_as_billing'] == 'on' ? $_POST['billing_same_as_customer'] == 'on' ? $_POST['update_customer_suburb'] : $_POST['update_billing_suburb'] : $_POST['update_delivery_suburb'])), 'delivery_city' => tep_db_input(tep_db_prepare_input(isset($_POST['shipping_same_as_billing']) && $_POST['shipping_same_as_billing'] == 'on' ? $_POST['billing_same_as_customer'] == 'on' ? $_POST['update_customer_city'] : $_POST['update_billing_city'] : $_POST['update_delivery_city'])), 'delivery_state' => tep_db_input(tep_db_prepare_input(isset($_POST['shipping_same_as_billing']) && $_POST['shipping_same_as_billing'] == 'on' ? $_POST['billing_same_as_customer'] == 'on' ? $update_customer_state : $update_billing_state : $update_delivery_state)), 'delivery_postcode' => tep_db_input(tep_db_prepare_input(isset($_POST['shipping_same_as_billing']) && $_POST['shipping_same_as_billing'] == 'on' ? $_POST['billing_same_as_customer'] == 'on' ? $_POST['update_customer_postcode'] : $_POST['update_billing_postcode'] : $_POST['update_delivery_postcode'])), 'delivery_country' => tep_db_input(tep_db_prepare_input(isset($_POST['shipping_same_as_billing']) && $_POST['shipping_same_as_billing'] == 'on' ? $_POST['billing_same_as_customer'] == 'on' ? $update_customer_country : $update_billing_country : $update_delivery_country)), 'payment_method' => tep_db_input(tep_db_prepare_input($_POST['update_info_payment_method'])), 'currency' => tep_db_input(tep_db_prepare_input($_POST['update_info_payment_currency'])), 'currency_value' => tep_db_input(tep_db_prepare_input($currency_value['value'])), 'cc_type' => tep_db_prepare_input($_POST['update_info_cc_type']), 'cc_owner' => tep_db_prepare_input($_POST['update_info_cc_owner']), 'cc_number' => tep_db_input(tep_db_prepare_input($_POST['update_info_cc_number'])), 'cc_expires' => tep_db_prepare_input($_POST['update_info_cc_expires']), 'last_modified' => 'now()');
 tep_db_perform(TABLE_ORDERS, $sql_data_array, 'update', 'orders_id = \'' . tep_db_input($oID) . '\'');
 $order_updated = true;
 // UPDATE STATUS HISTORY & SEND EMAIL TO CUSTOMER IF NECESSARY #####
 $check_status_query = tep_db_query(" SELECT customers_name, customers_email_address, orders_status, date_purchased FROM " . TABLE_ORDERS . " WHERE orders_id = '" . (int) $oID . "'");
 $check_status = tep_db_fetch_array($check_status_query);
 if ($check_status['orders_status'] != $_POST['status'] || tep_not_null($_POST['comments'])) {
     tep_db_query("UPDATE " . TABLE_ORDERS . " SET \n              orders_status = '" . tep_db_input($_POST['status']) . "', \n              last_modified = now() \n              WHERE orders_id = '" . (int) $oID . "'");
     // Notify Customer ?
     $customer_notified = '0';
     if (isset($_POST['notify']) && $_POST['notify'] == 'on') {
         $notify_comments = '';
         if (isset($_POST['notify_comments']) && $_POST['notify_comments'] == 'on') {
             $notify_comments = sprintf(EMAIL_TEXT_COMMENTS_UPDATE, $_POST['comments']) . "\n\n";
         }
$firstname = tep_db_prepare_input($_POST['customers_firstname']);
$lastname = tep_db_prepare_input($_POST['customers_lastname']);
$dob = tep_db_prepare_input($_POST['customers_dob']);
$email_address = tep_db_prepare_input($_POST['customers_email_address']);
$telephone = tep_db_prepare_input($_POST['customers_telephone']);
$fax = tep_db_prepare_input($_POST['customers_fax']);
$newsletter = tep_db_prepare_input($_POST['newsletter']);
$confirmation = tep_db_prepare_input($_POST['confirmation']);
$street_address = tep_db_prepare_input($_POST['entry_street_address']);
$company = tep_db_prepare_input($_POST['entry_company']);
$suburb = tep_db_prepare_input($_POST['entry_suburb']);
$postcode = tep_db_prepare_input($_POST['entry_postcode']);
$city = tep_db_prepare_input($_POST['entry_city']);
$zone_id = empty($_POST['zone_id']) ? 0 : tep_db_prepare_input($_POST['zone_id']);
$state = tep_db_prepare_input($_POST['entry_state']);
$country = tep_db_prepare_input(tep_get_country_name($_POST['entry_country']));
$country_id = (int) tep_db_prepare_input($_POST['entry_country']);
$customers_newsletter = tep_db_prepare_input($_POST['customers_newsletter']);
$customers_password = tep_db_prepare_input($_POST['customers_password']);
$format_id = tep_get_address_format_id($country_id);
$size = "1";
$payment_method = DEFAULT_PAYMENT_METHOD;
$new_value = "1";
$error = false;
// reset error flag
$temp_amount = "0";
$temp_amount = number_format($temp_amount, 2, '.', '');
$currency_text = DEFAULT_CURRENCY . ", 1";
if (isset($_POST['Currency'])) {
    $currency_text = tep_db_prepare_input($_POST['Currency']);
}
Example #14
0
         </tr>
<?php 
    }
    ?>
          <tr>
            <td class="main"><?php 
    echo ENTRY_COUNTRY;
    ?>
</td>
            <td class="main">
<?php 
    if ($error == true) {
        if ($entry_country_error == true) {
            echo tep_draw_pull_down_menu('entry_country_id', tep_get_countries(), $cInfo->entry_country_id) . '&nbsp;' . ENTRY_COUNTRY_ERROR;
        } else {
            echo tep_get_country_name($cInfo->entry_country_id) . tep_draw_hidden_field('entry_country_id');
        }
    } else {
        echo tep_draw_pull_down_menu('entry_country_id', tep_get_countries(), $cInfo->entry_country_id);
    }
    ?>
</td>
          </tr>
        </table></td>
      </tr>
      <tr>
        <td><?php 
    echo tep_draw_separator('pixel_trans.gif', '1', '10');
    ?>
</td>
      </tr>
Example #15
0
<?php

switch ($action) {
    case 'new':
        $adv_info = array();
        if (tep_not_null($HTTP_POST_VARS)) {
            $adv_info = $HTTP_POST_VARS;
        } else {
            $customer_info_query = tep_db_query("select customers_email_address, customers_telephone from " . TABLE_CUSTOMERS . " where customers_id = '" . (int) $customer_id . "'");
            $customer_info = tep_db_fetch_array($customer_info_query);
            if ($customer_default_address_id > 0) {
                $adv_info_query = tep_db_query("select entry_city as customers_city, entry_state as customers_state, entry_country_id, entry_telephone as customers_telephone from " . TABLE_ADDRESS_BOOK . " where customers_id = '" . (int) $customer_id . "' and address_book_id = '" . (int) $customer_default_address_id . "' order by address_book_id desc limit 1");
                $adv_info = tep_db_fetch_array($adv_info_query);
                $adv_info['customers_country'] = tep_get_country_name($adv_info['entry_country_id']);
            } else {
                $all_countries = tep_get_shops_countries();
                $customer_country_code = isset($_SERVER['GEOIP_COUNTRY_CODE']) ? $_SERVER['GEOIP_COUNTRY_CODE'] : tep_get_ip_info();
                reset($all_countries);
                while (list(, $country_info) = each($all_countries)) {
                    if ($country_info['country_code'] == $customer_country_code) {
                        $adv_info['customers_country'] = $country_info['country_name'];
                        break;
                    }
                }
            }
            $adv_info['customers_name'] = preg_replace('/\\s{2,}/', ' ', trim($customer_first_name . ' ' . $customer_middle_name . ' ' . $customer_last_name));
            $adv_info['boards_condition'] = '5';
            $adv_info['boards_quantity'] = '1';
            $adv_info = array_merge($customer_info, $adv_info);
            if (isset($HTTP_GET_VARS['products_id'])) {
                $product_info_query = tep_db_query("select products_id, products_model, products_year, authors_id, manufacturers_id from " . TABLE_PRODUCTS . " where products_id = '" . (int) $HTTP_GET_VARS['products_id'] . "'");
Example #16
0
function tep_address_format($address_format_id, $address, $html, $boln, $eoln)
{
    $address_format_query = tep_db_query("select address_format as format from " . TABLE_ADDRESS_FORMAT . " where address_format_id = '" . (int) $address_format_id . "'");
    $address_format = tep_db_fetch_array($address_format_query);
    $company = tep_output_string_protected($address['company']);
    if (isset($address['firstname']) && tep_not_null($address['firstname'])) {
        $firstname = tep_output_string_protected($address['firstname']);
        $lastname = tep_output_string_protected($address['lastname']);
    } elseif (isset($address['name']) && tep_not_null($address['name'])) {
        $firstname = tep_output_string_protected($address['name']);
        $lastname = '';
    } else {
        $firstname = '';
        $lastname = '';
    }
    $street = tep_output_string_protected($address['street_address']);
    $suburb = tep_output_string_protected($address['suburb']);
    $city = tep_output_string_protected($address['city']);
    $state = tep_output_string_protected($address['state']);
    if (isset($address['country_id']) && tep_not_null($address['country_id'])) {
        $country = tep_get_country_name($address['country_id']);
        if (isset($address['zone_id']) && tep_not_null($address['zone_id'])) {
            $state = tep_get_zone_code($address['country_id'], $address['zone_id'], $state);
        }
    } elseif (isset($address['country']) && tep_not_null($address['country'])) {
        $country = tep_output_string_protected($address['country']);
    } else {
        $country = '';
    }
    $postcode = tep_output_string_protected($address['postcode']);
    $zip = $postcode;
    if ($html) {
        // HTML Mode
        $HR = '<hr />';
        $hr = '<hr />';
        if ($boln == '' && $eoln == "\n") {
            // Values not specified, use rational defaults
            $CR = '<br />';
            $cr = '<br />';
            $eoln = $cr;
        } else {
            // Use values supplied
            $CR = $eoln . $boln;
            $cr = $CR;
        }
    } else {
        // Text Mode
        $CR = $eoln;
        $cr = $CR;
        $HR = '----------------------------------------';
        $hr = '----------------------------------------';
    }
    $statecomma = '';
    $streets = $street;
    if ($suburb != '') {
        $streets = $street . $cr . $suburb;
    }
    if ($country == '') {
        $country = tep_output_string_protected($address['country']);
    }
    if ($state != '') {
        $statecomma = $state . ', ';
    }
    $fmt = $address_format['format'];
    eval("\$address = \"{$fmt}\";");
    if (ACCOUNT_COMPANY == 'true' && tep_not_null($company)) {
        $address = $company . $cr . $address;
    }
    return $address;
}
 public function output($step = 0)
 {
     global $customer_id, $temp_orders_id;
     $html = '';
     if (tep_session_is_registered('customer_id')) {
         //show address book item form
         if (isset($_GET['add_new_address']) && $_GET['add_new_address'] == 'true' && $this->config['change_billing_address']['value'] == 'true') {
             $html .= '<h3>' . Translate('Voeg nieuw adres toe') . '</h3>';
             $html .= '<div class="well">';
             if (count($this->errors[get_class($this)]['address_book']) > 0) {
                 $html .= '<div class="alert alert-error"><strong>' . Translate('Opgelet!') . '</strong> ' . Translate('Vul a.u.b. alle velden correct in.') . '</div>';
             }
             $html .= '<div class="address_book_item">';
             $html .= '<input type="hidden" name="save_new_address" value="true" />';
             //get fields from db
             $ab_query = tep_db_query('SHOW columns FROM address_book');
             while ($ab_fields = tep_db_fetch_array($ab_query)) {
                 foreach ($this->fields[key($this->fields)]['fields'] as $field => $field_data) {
                     if ($field_data['dbvalue'] == $ab_fields['Field']) {
                         if ($field_data['condition'] != '') {
                             $show_field = eval($field_data['condition'] . ';');
                         } else {
                             $show_field = true;
                         }
                         if ($show_field) {
                             //check if there where errors with the filled in data for this field
                             $class = '';
                             if ($this->errors[get_class($this)]['address_book'][$field_data['dbvalue']]) {
                                 $class .= ' error';
                                 //$html .= parent::create_error($this->errors[get_class($this)]['address_book'][$field]);
                                 unset($this->errors[get_class($this)]['address_book'][$field_data['dbvalue']]);
                             }
                             $html .= '<div class="control-group' . $class . '">';
                             $html .= '<label class="control-label" for="address_book_item_' . $field_data['dbvalue'] . '">' . $field_data['label'] . '</label>';
                             $html .= '<div class="controls">';
                             if ($field_data['type'] == 'dropdown') {
                                 if (strstr($field_data['dbvalue'], 'country')) {
                                     $html .= parent::get_country_list($field_data['dbvalue'], $_POST[$field_data['dbvalue']], 'id="address_book_item_' . $field_data['dbvalue'] . '"');
                                 }
                             } else {
                                 $html .= '<input type="' . $field_data['input'] . '" id="address_book_item_' . $field_data['dbvalue'] . '" name="' . $field_data['dbvalue'] . '" value="' . htmlspecialchars(stripslashes($_POST[$field_data['dbvalue']])) . '" />';
                             }
                             $html .= '</div>';
                             //end controle
                             $html .= '</div>';
                             //end control-group
                         }
                     }
                 }
             }
             $html .= '<div class="form-actions">';
             //submit
             $html .= '<button type="submit" class="btn btn-success">' . Translate('Nieuw adres opslaan') . '</button> ';
             //cancel
             $html .= '<button type="submit" name="action" value="cancel" class="btn">' . Translate('Annuleren') . '</button>';
             $html .= '</div>';
             //end form actions
             $html .= '</div>';
             //end address_book_item
             $html .= '</div>';
             //end well
             //eof address book item form
         } else {
             //address list
             //list address book items
             //get customers_info if customer is logged in
             $c_query = tep_db_query('SELECT customers_email_address, customers_telephone, customers_default_address_id FROM customers WHERE customers_id = "' . $customer_id . '"');
             $c = tep_db_fetch_array($c_query);
             //check if address_id's are known
             if ($temp_orders_id > 0) {
                 $a_id_query = tep_db_query('SELECT delivery_address_id, billing_address_id FROM temp_orders WHERE orders_id = "' . $temp_orders_id . '"');
                 $a_id = tep_db_fetch_array($a_id_query);
             }
             $count = 0;
             $max_count = count($this->fields);
             if (is_array($this->errors[get_class($this)]['address_book_list'])) {
                 foreach ($this->errors[get_class($this)]['address_book_list'] as $error) {
                     $html .= '<div class="alert alert-error"><strong>' . Translate('Opgelet!') . '</strong> ' . $error . '</div>';
                 }
             }
             $html .= '<div class="row-fluid">';
             //foreach block (billing, delivery, ...)
             //  echo "<script type='text/javascript'>var one_check = 0 ;if(one_check != 2){window.history.go(-1);}one_check=2;</script>";
             foreach ($this->fields as $block => $block_data) {
                 $is_checked = false;
                 $count++;
                 $html .= '<div class="span6">';
                 //title eg. 'Facturatie adres', 'leveringsadres', ...
                 $html .= '<h3>' . $block_data['title'] . '</h3>';
                 $html .= '<div class="well">';
                 $html .= '<ul class="address_list">';
                 if ($block == 'billing' && $this->config['change_billing_address']['value'] == 'false') {
                     $ab_query = tep_db_query('SELECT * FROM address_book WHERE customers_id = "' . $customer_id . '" AND entry_country_id IN ("' . implode('", "', parent::$available_countries) . '") AND address_book_id = "' . $c['customers_default_address_id'] . '"');
                 } else {
                     $ab_query = tep_db_query('SELECT * FROM address_book WHERE customers_id = "' . $customer_id . '" AND entry_country_id IN ("' . implode('", "', parent::$available_countries) . '")');
                 }
                 while ($ab = tep_db_fetch_array($ab_query)) {
                     $html .= '<li class="address_block clearfix">';
                     //radio button
                     if (!$is_checked) {
                         if ($_POST['address_book_id'][$block] == $ab['address_book_id']) {
                             $checked = ' checked=checked';
                             $is_checked = true;
                         } else {
                             if (isset($a_id[$block . '_address_id']) && $a_id[$block . '_address_id'] == $ab['address_book_id']) {
                                 $checked = ' checked=checked';
                                 $is_checked = true;
                             } else {
                                 if ($c['customers_default_address_id'] == $ab['address_book_id']) {
                                     $checked = ' checked=checked';
                                     $is_checked = true;
                                 }
                             }
                         }
                     } else {
                         $checked = '';
                     }
                     $html .= '<input type="radio" id="address_book_id_' . $block . '_' . $ab['address_book_id'] . '" name="address_book_id[' . $block . ']" value="' . $ab['address_book_id'] . '"' . $checked . ' />';
                     $html .= '<label for="address_book_id_' . $block . '_' . $ab['address_book_id'] . '">';
                     $html .= '<div class="address">';
                     //name
                     $html .= '<div class="address_name">' . convert_to_entities($ab['entry_firstname']) . '</div>';
                     //street
                     $html .= '<div class="address_street">' . convert_to_entities($ab['entry_street_address']) . '</div>';
                     //city + postcode + country
                     $html .= '<div class="address_city">' . $ab['entry_postcode'] . ' ' . convert_to_entities($ab['entry_city']) . ' ' . convert_to_entities(tep_get_country_name($ab['entry_country_id'])) . '</div>';
                     $html .= '</div>';
                     //end address
                     $html .= '</label>';
                     //link to delete address book item
                     if ($c['customers_default_address_id'] == $ab['address_book_id']) {
                         $html .= '<div class="delete_address">[' . Translate('Hoofdadres') . ']</div>';
                     } else {
                         $html .= '<div class="delete_address"><a href="' . tep_href_link(basename($_SERVER['PHP_SELF']), 'delete_address=' . $ab['address_book_id']) . '" title="' . Translate('Verwijder adres') . '" class="btn btn-mini">' . Translate('Verwijder adres') . '</a></div>';
                     }
                     $html .= '</li>';
                     //end address_block
                 }
                 $html .= '</ul>';
                 //end address_list
                 //link to add new address book item
                 if ($block == 'billing' && $this->config['change_billing_address']['value'] == 'true' || $block != 'billing') {
                     $html .= '<div class="add_new_address"><a href="' . tep_href_link(basename($_SERVER['PHP_SELF']), 'checkout_step=' . $step . '&add_new_address=true') . '" title="' . Translate('Nieuw adres toevoegen') . '" class="btn btn-mini"><i class="icon-plus-sign"></i> ' . Translate('Nieuw adres toevoegen') . '</a></div>';
                 }
                 $html .= '</div>';
                 //end well
                 $html .= '</div>';
                 //end span6
             }
             $html .= '</div>';
             //end row-fluid
             //eof address list
         }
     } else {
         //Not logged in
         //get last filled in data if that is available
         if ($temp_orders_id > 0) {
             $to_query = tep_db_query('SELECT * FROM temp_orders WHERE orders_id = "' . $temp_orders_id . '"');
             if (tep_db_num_rows($to_query) > 0) {
                 $to = tep_db_fetch_array($to_query);
                 if (!isset($_POST['customers_info_data'])) {
                     //check if there where errors in that step
                     $tos_query = tep_db_query('SELECT errors FROM temp_orders_steps WHERE orders_id ="' . $temp_orders_id . '" AND step = "' . $step . '" ORDER BY date desc LIMIT 1');
                     if (tep_db_num_rows($tos_query) > 0) {
                         $tos = tep_db_fetch_array($tos_query);
                         $tos['errors'] = unserialize($tos['errors']);
                         $this->errors = $tos['errors'][get_class($this)];
                     }
                 }
             }
         }
         //create form
         $html .= '<input type="hidden" name="customers_info_data" value="true" />';
         /************************/
         /*  show login block?   */
         /************************/
         if ($this->config['login']['value'] == 'true' && !tep_session_is_registered('customer_id')) {
             //login box
             if (!empty($this->errors[get_class($this)]['login'])) {
                 $html .= '<div class="alert alert-error">' . $this->errors[get_class($this)]['login'] . '</div>';
             }
             $html .= Translate('Terugkerende klant') . '? ';
             $html .= '<a href="#" id="login_modal_button" style="display:none;">' . Translate('Inloggen') . '</a>';
             $html .= '<div class="well form-inline login_modal" id="login_block">';
             $html .= '<h2>' . Translate('Inloggen') . '</h2>';
             $html .= '<div class="control-group">';
             //email
             $html .= '<input type="text" name="login_email" placeholder="' . Translate('E-mailadres') . '" value="' . $_POST['login_email'] . '" /> ';
             //password
             $html .= '<input type="password" placeholder="' . Translate('Paswoord') . '" name="login_pass" value="" />';
             $html .= '</div>';
             //submit
             $html .= ' <button type="submit" name="action" value="login" class="btn">' . Translate('Log in') . '</button>';
             $html .= '</div>';
             //end well
             $html .= '</form>';
             $html .= '<form name="process_step2" method="POST" action="' . tep_href_link(basename($_SERVER['PHP_SELF'])) . '" class="form-inline">';
             $html .= '<input type="hidden" name="checkout_step" value="' . $step . '" />';
             $html .= '<input type="hidden" name="checkout_modules[]" value="' . get_class($this) . '" />';
             $html .= '<input type="hidden" name="customers_info_data" value="true" />';
             //eof login box
         }
         $html .= '<div class="row-fluid">';
         /************************************************************************/
         /*  show all blocks eg 'billing', 'delivery' with there active fields   */
         /************************************************************************/
         foreach ($this->fields as $block => $block_data) {
             //if this is the delivery block, show checkbox for different delivery address then billing address
             $html .= '<div class="span6">';
             $html .= '<h3>' . $block_data['title'] . '</h3>';
             if ($this->errors[get_class($this)][$block]) {
                 $html .= '<div class="alert alert-error">' . Translate('Vul a.u.b. alle velden correct in.') . '</div>';
             }
             $html .= '<div class="well">';
             if ($block == 'delivery') {
                 //Check if delivery and billing address are different
                 $different_address = false;
                 foreach ($this->fields['delivery']['fields'] as $field => $field_data) {
                     foreach ($this->fields['billing']['fields'] as $bfield => $bfield_data) {
                         if ($field_data['dbvalue'] == $bfield_data['dbvalue']) {
                             if ($to[$field] != $to[$bfield]) {
                                 $different_address = true;
                                 continue 2;
                             }
                             continue 1;
                         }
                     }
                 }
                 //checkbox
                 $html .= '<div class="control-group">';
                 $html .= '<div class="controls" id="showDelivery">';
                 $html .= '<input class="form-checkbox" type="checkbox" id="check_different_delivery_address" name="different_delivery_address" value="true"' . ($_POST['different_delivery_address'] == 'true' ? ' checked=checked' : ($different_address ? ' checked=checked' : '')) . ' />';
                 $html .= '<label class="checkbox inline" for="check_different_delivery_address" id="label_different_delivery_address">';
                 $html .= Translate('Leveringsadres is verschillend van facturatieadres.');
                 $html .= '</label>';
                 $html .= '</div>';
                 //end controls
                 $html .= '</div>';
                 //end control-group
             }
             //block title eg. 'Facturatie adres', 'leveringsadres', ...
             foreach ($block_data['fields'] as $field => $field_data) {
                 if ($field_data['condition'] != '') {
                     eval(stripslashes($field_data['condition']) . ';');
                 } else {
                     $show_field = true;
                 }
                 if ($show_field) {
                     //check if there where errors with the filled in data for this field
                     $class = '';
                     if ($block == 'delivery') {
                         $class .= ' hideDelivery';
                     }
                     if ($this->errors[get_class($this)][$block][$field]) {
                         $class .= ' error';
                         $html .= '<div class="form-error">' . Translate($this->errors[get_class($this)][$block][$field]) . '</div>';
                     }
                     $html .= '<div class="control-group' . $class . '">';
                     $html .= '<label class="control-label" for="' . get_class($this) . '_input_' . $field . '">' . $field_data['label'] . '</label>';
                     $html .= '<div class="controls">';
                     if ($field_data['type'] == 'dropdown') {
                         if (strstr($field, 'country')) {
                             $html .= parent::get_country_list(get_class($this) . '_' . $field, isset($_POST[get_class($this) . '_' . $field]) ? $_POST[get_class($this) . '_' . $field] : $to[$field], 'id="' . get_class($this) . '_input_' . $field . '"');
                         }
                     } else {
                         if ($field_data['name'] == 'billing_firstname') {
                             if (isset($_POST[get_class($this) . '_' . $field])) {
                                 $billing_firstname = $_POST[get_class($this) . '_' . $field];
                             } else {
                                 $billing_firstname = $to['billing_name'];
                                 $billing_firstname = end(explode(' ', $billing_firstname));
                             }
                             $html .= '<input type="' . $field_data['input'] . '" id="' . get_class($this) . '_input_' . $field . '" name="' . get_class($this) . '_' . $field . '" value="' . $billing_firstname . '" />';
                         } else {
                             if ($field_data['name'] == 'billing_lastname') {
                                 if (isset($_POST[get_class($this) . '_' . $field])) {
                                     $billing_lastname = $_POST[get_class($this) . '_' . $field];
                                 } else {
                                     $billing_lastname = $to['billing_name'];
                                     $billing_lastname_temp = end(explode(' ', $billing_lastname));
                                     $billing_lastname = substr($billing_lastname, 0, -strlen($billing_lastname_temp));
                                 }
                                 $html .= '<input type="' . $field_data['input'] . '" id="' . get_class($this) . '_input_' . $field . '" name="' . get_class($this) . '_' . $field . '" value="' . $billing_lastname . '" />';
                             } else {
                                 if ($field_data['name'] == 'delivery_firstname') {
                                     if (isset($_POST[get_class($this) . '_' . $field])) {
                                         $delivery_firstname = $_POST[get_class($this) . '_' . $field];
                                     } else {
                                         $delivery_firstname = $to['delivery_name'];
                                         $delivery_firstname = end(explode(' ', $delivery_firstname));
                                     }
                                     $html .= '<input type="' . $field_data['input'] . '" id="' . get_class($this) . '_input_' . $field . '" name="' . get_class($this) . '_' . $field . '" value="' . $delivery_firstname . '" />';
                                 } else {
                                     if ($field_data['name'] == 'delivery_lastname') {
                                         if (isset($_POST[get_class($this) . '_' . $field])) {
                                             $delivery_lastname = $_POST[get_class($this) . '_' . $field];
                                         } else {
                                             $delivery_lastname = $to['delivery_name'];
                                             $delivery_lastname_temp = end(explode(' ', $delivery_lastname));
                                             $delivery_lastname = substr($delivery_lastname, 0, -strlen($delivery_lastname_temp));
                                         }
                                         $html .= '<input type="' . $field_data['input'] . '" id="' . get_class($this) . '_input_' . $field . '" name="' . get_class($this) . '_' . $field . '" value="' . $delivery_lastname . '" />';
                                         ////////////////////////////////////////////////////////////////* #1539 - Shipping address
                                     } else {
                                         if ($field_data['name'] == 'delivery_telephone' && $to['delivery_telephone'] == '') {
                                             $delivery_telephone = $to['customers_telephone'];
                                             $html .= '<input type="' . $field_data['input'] . '" id="' . get_class($this) . '_input_' . $field . '" name="' . get_class($this) . '_' . $field . '" value="' . $delivery_telephone . '" />';
                                             ////////////////////////////////////////////////////////////////* #1539 - Shipping address
                                         } else {
                                             $html .= '<input type="' . $field_data['input'] . '" id="' . get_class($this) . '_input_' . $field . '" name="' . get_class($this) . '_' . $field . '" value="' . (isset($_POST[get_class($this) . '_' . $field]) ? $_POST[get_class($this) . '_' . $field] : $to[$field]) . '" />';
                                         }
                                     }
                                 }
                             }
                         }
                     }
                     $html .= '</div>';
                     //end controle
                     $html .= '</div>';
                     //end control-group
                 }
             }
             $html .= '</div>';
             //end well
             $html .= '</div>';
             //end span6
         }
         $html .= '</div>';
         //end row-fluid
         if ($this->config['create_account']['value'] == 'true' && !tep_session_is_registered('customer_id')) {
             $html .= '<div class="alert alert-error" id="emailCheck" style="display:none;">' . Translate('Het ingegeven e-mailadres bestaat al in ons systeem. Gelieve  een  te registreren met een ander e-mailadres') . '</div>';
             $html .= '<a href="#" id="show_create_account_button" style="display:none;margin-bottom:5px;">' . Translate('Uw gegevens onthouden voor de volgende keer?') . '</a>';
             $html .= '<div id="create_account_block">';
             $html .= '<h3>' . Translate('Maak een account aan') . '</h3>';
             $html .= '<div class="well form-inline">';
             if (!empty($this->errors[get_class($this)]['create_account'])) {
                 $html .= '<div class="alert alert-error">' . $this->errors[get_class($this)]['create_account'] . '</div>';
             }
             //Terms
             $html .= '<div id="CAparagraph">';
             $html .= tep_draw_checkbox_field('TermsAgree', 'true', false, 'id="TermsAgree"');
             $html .= '<label for="TermsAgree">';
             $termsAgree = sprintf(Translate("Ik heb de %s gelezen en ga hiermee akkoord"), '<a href="' . tep_href_link('conditions_modal.php') . '" target="_blank">' . Translate('Algemene voorwaarden') . '</a>');
             if (CONDITIONS_CREATE_ACCOUNT == 'Link') {
                 $html .= $termsAgree;
             } else {
                 $html .= strip_tags($termsAgree);
             }
             $html .= '</label>';
             $html .= '</div>';
             //Password field
             $html .= '<input type="password" id="' . get_class($this) . '_input_password" name="' . get_class($this) . '_password" value="' . (isset($_POST[get_class($this) . '_password']) ? $_POST[get_class($this) . '_password'] : '') . '" placeholder="' . Translate('Wachtwoord') . '" />&nbsp;';
             //Password2 field
             $html .= '<input type="password" id="' . get_class($this) . '_input_password2" name="' . get_class($this) . '_password2" value="' . (isset($_POST[get_class($this) . '_password2']) ? $_POST[get_class($this) . '_password2'] : '') . '" placeholder="' . Translate('Wachtwoord bevestigen') . '" />&nbsp;';
             //Create account button
             $html .= '<button type="submit" name="action" value="create_account" class="btn">' . Translate('Registreer') . '</button>';
             $html .= '</div>';
             //end well
             $html .= '</div>';
             //End create_account_block
         }
     }
     return $html;
 }
Example #18
0
     }
     $contents[] = array('text' => '<br>' . TEXT_INFO_COUNTRY_NAME . $countries_inputs_string);
     $contents[] = array('text' => '<br>' . TEXT_INFO_COUNTRY_CODE_2 . '<br>' . tep_draw_input_field('countries_iso_code_2'));
     $contents[] = array('text' => '<br>' . TEXT_INFO_COUNTRY_CODE_3 . '<br>' . tep_draw_input_field('countries_iso_code_3'));
     $contents[] = array('text' => '<br>' . TEXT_INFO_ADDRESS_FORMAT . '<br>' . tep_draw_pull_down_menu('address_format_id', tep_get_address_formats()));
     $contents[] = array('text' => '<br>' . TEXT_INFO_SORT_ORDER . '<br>' . tep_draw_input_field('sort_order', '', 'size="5"'));
     $contents[] = array('align' => 'center', 'text' => '<br>' . tep_image_submit('button_insert.gif', IMAGE_INSERT) . '&nbsp;<a href="' . tep_href_link(FILENAME_COUNTRIES, 'page=' . $HTTP_GET_VARS['page']) . '">' . tep_image_button('button_cancel.gif', IMAGE_CANCEL) . '</a>');
     break;
 case 'edit':
     $heading[] = array('text' => '<strong>' . TEXT_INFO_HEADING_EDIT_COUNTRY . '</strong>');
     $contents = array('form' => tep_draw_form('countries', FILENAME_COUNTRIES, 'page=' . $HTTP_GET_VARS['page'] . '&cID=' . $cInfo->countries_id . '&action=save'));
     $contents[] = array('text' => TEXT_INFO_EDIT_INTRO);
     $countries_inputs_string = '';
     $languages = tep_get_languages();
     for ($i = 0, $n = sizeof($languages); $i < $n; $i++) {
         $countries_inputs_string .= '<br>' . tep_image(DIR_WS_CATALOG_IMAGES . $languages[$i]['image'], $languages[$i]['name'], '', '', 'style="float: left; margin: 4px 4px 0px 0px;"') . tep_draw_input_field('countries_name[' . $languages[$i]['id'] . ']', tep_get_country_name($cInfo->countries_id, $languages[$i]['id']), 'size=32');
     }
     $contents[] = array('text' => '<br>' . TEXT_INFO_COUNTRY_NAME . $countries_inputs_string);
     $contents[] = array('text' => '<br>' . TEXT_INFO_COUNTRY_CODE_2 . '<br>' . tep_draw_input_field('countries_iso_code_2', $cInfo->countries_iso_code_2));
     $contents[] = array('text' => '<br>' . TEXT_INFO_COUNTRY_CODE_3 . '<br>' . tep_draw_input_field('countries_iso_code_3', $cInfo->countries_iso_code_3));
     $contents[] = array('text' => '<br>' . TEXT_INFO_ADDRESS_FORMAT . '<br>' . tep_draw_pull_down_menu('address_format_id', tep_get_address_formats(), $cInfo->address_format_id));
     $contents[] = array('text' => '<br>' . TEXT_INFO_SORT_ORDER . '<br>' . tep_draw_input_field('sort_order', $cInfo->sort_order, 'size="5"'));
     $contents[] = array('align' => 'center', 'text' => '<br>' . tep_image_submit('button_update.gif', IMAGE_UPDATE) . '&nbsp;<a href="' . tep_href_link(FILENAME_COUNTRIES, 'page=' . $HTTP_GET_VARS['page'] . '&cID=' . $cInfo->countries_id) . '">' . tep_image_button('button_cancel.gif', IMAGE_CANCEL) . '</a>');
     break;
 case 'delete':
     $heading[] = array('text' => '<strong>' . TEXT_INFO_HEADING_DELETE_COUNTRY . '</strong>');
     $contents = array('form' => tep_draw_form('countries', FILENAME_COUNTRIES, 'page=' . $HTTP_GET_VARS['page'] . '&cID=' . $cInfo->countries_id . '&action=deleteconfirm'));
     $contents[] = array('text' => TEXT_INFO_DELETE_INTRO);
     $contents[] = array('text' => '<br><strong>' . $cInfo->countries_name . '</strong>');
     $contents[] = array('align' => 'center', 'text' => '<br>' . tep_image_submit('button_delete.gif', IMAGE_UPDATE) . '&nbsp;<a href="' . tep_href_link(FILENAME_COUNTRIES, 'page=' . $HTTP_GET_VARS['page'] . '&cID=' . $cInfo->countries_id) . '">' . tep_image_button('button_cancel.gif', IMAGE_CANCEL) . '</a>');
     break;
 public function output($step = 0)
 {
     global $temp_orders_id;
     $html = '';
     if ($temp_orders_id > 0) {
         $to_query = tep_db_query('SELECT * FROM temp_orders WHERE orders_id = "' . $temp_orders_id . '"');
         if (tep_db_num_rows($to_query) > 0) {
             $to = tep_db_fetch_array($to_query);
             $html .= '<div class="billing_address">';
             $html .= '<h3 class="billing_address_title">' . Translate($this->config['title']) . '</h3>';
             if (!empty($this->config['description'])) {
                 $html .= '<p class="billing_address_description">' . Translate($this->config['description']) . '</p>';
             }
             $html .= '<blockquote>';
             $html .= '<address>';
             //name
             $html .= '<strong>' . $to['billing_name'] . '</strong><br />';
             //street
             $html .= $to['billing_street_address'] . '<br />';
             //city + postcode + country
             $html .= $to['billing_postcode'] . ' ' . $to['billing_city'] . ' ' . tep_get_country_name($to['billing_country']) . '<br />';
             $html .= '</address>';
             $html .= '</blockquote>';
             $html .= '</div>';
             //end billing_address
         }
     }
     return $html;
 }