From 2bf4ef91968c7f0d307c672073ee41ef3762fc70 Mon Sep 17 00:00:00 2001
From: mDeflotte
Date: Tue, 6 Dec 2011 13:18:00 +0000
Subject: [PATCH] // Removing numerics from order reference
---
classes/Tools.php | 17 +++++++++++++++--
classes/order/Order.php | 4 +---
modules/bankwire/payment_return.tpl | 7 +++++--
modules/cheque/payment_return.tpl | 5 +++++
4 files changed, 26 insertions(+), 7 deletions(-)
diff --git a/classes/Tools.php b/classes/Tools.php
index c993cbb7c..592dc8c9e 100644
--- a/classes/Tools.php
+++ b/classes/Tools.php
@@ -35,11 +35,24 @@ class ToolsCore
* Random password generator
*
* @param integer $length Desired length (optional)
+ * @param string $flag Output type (NUMERIC, ALPHANUMERIC, NO_NUMERIC)
* @return string Password
*/
- public static function passwdGen($length = 8)
+ public static function passwdGen($length = 8, $flag = 'ALPHANUMERIC')
{
- $str = 'abcdefghijkmnopqrstuvwxyz0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ';
+ switch ($flag)
+ {
+ case 'NUMERIC':
+ $str = '0123456789';
+ break;
+ case 'NO_NUMERIC':
+ $str = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ';
+ break;
+ default:
+ $str = 'abcdefghijkmnopqrstuvwxyz0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ';
+ break;
+ }
+
for ($i = 0, $passwd = ''; $i < $length; $i++)
$passwd .= self::substr($str, mt_rand(0, self::strlen($str) - 1), 1);
return $passwd;
diff --git a/classes/order/Order.php b/classes/order/Order.php
index 0287b9532..1373f5363 100644
--- a/classes/order/Order.php
+++ b/classes/order/Order.php
@@ -1292,9 +1292,7 @@ class OrderCore extends ObjectModel
*/
public static function generateReference()
{
- // To generate a random reference, we first generate a random number
- // This number is a rand concated with the current timestamp
- return strtoupper(Tools::passwdGen(9)); // lol Max !
+ return strtoupper(Tools::passwdGen(9, 'NO_NUMERIC'));
}
public function orderContainProduct($id_product)
diff --git a/modules/bankwire/payment_return.tpl b/modules/bankwire/payment_return.tpl
index 1fc35abb6..51a12b6b6 100644
--- a/modules/bankwire/payment_return.tpl
+++ b/modules/bankwire/payment_return.tpl
@@ -32,8 +32,11 @@
- {l s='to the account owner of' mod='bankwire'} {if $bankwireOwner}{$bankwireOwner}{else}___________{/if}
- {l s='with these details' mod='bankwire'} {if $bankwireDetails}{$bankwireDetails}{else}___________{/if}
- {l s='to this bank' mod='bankwire'} {if $bankwireAddress}{$bankwireAddress}{else}___________{/if}
-
- {l s='Do not forget to insert your order #' mod='bankwire'} {$id_order} {l s='in the subject of your bank wire' mod='bankwire'}
-
{l s='An e-mail has been sent to you with this information.' mod='bankwire'}
+ {if !isset($reference)}
+
- {l s='Do not forget to insert your order number #' mod='bankwire'} {$id_order} {l s='in the subject of your bank wire' mod='bankwire'}
+ {else}
+
- {l s='Do not forget to insert your order reference' mod='bankwire'} {$reference} {l s='in the subject of your bank wire' mod='bankwire'}
+ {/if}
{l s='An e-mail has been sent to you with this information.' mod='bankwire'}
{l s='Your order will be sent as soon as we receive your settlement.' mod='bankwire'}
{l s='For any questions or for further information, please contact our' mod='bankwire'} {l s='customer support' mod='bankwire'}.
diff --git a/modules/cheque/payment_return.tpl b/modules/cheque/payment_return.tpl
index bceda1cc8..55699e9a5 100644
--- a/modules/cheque/payment_return.tpl
+++ b/modules/cheque/payment_return.tpl
@@ -31,6 +31,11 @@
- {l s='an amount of' mod='cheque'} {$total_to_pay}
- {l s='payable to the order of' mod='cheque'} {if $chequeName}{$chequeName}{else}___________{/if}
- {l s='mail to' mod='cheque'} {if $chequeAddress}{$chequeAddress}{else}___________{/if}
+ {if !isset($reference)}
+
- {l s='Do not forget to insert your order number #' mod='cheque'} {$id_order}
+ {else}
+
- {l s='Do not forget to insert your order reference' mod='cheque'} {$reference}
+ {/if}
{l s='An e-mail has been sent to you with this information.' mod='cheque'}
{l s='Your order will be sent as soon as we receive your payment.' mod='cheque'}
{l s='For any questions or for further information, please contact our' mod='cheque'} {l s='customer support' mod='cheque'}.