[*] Core: you can now associate modules to order states in order to add extra mail vars

git-svn-id: http://dev.prestashop.com/svn/v1/branches/1.5.x@16618 b9a71923-0436-4b27-9f14-aed3839534dd
This commit is contained in:
rGaillard
2012-07-31 09:18:41 +00:00
parent 58f7fb1c03
commit b37a36eba5
9 changed files with 41 additions and 18 deletions
+9 -1
View File
@@ -310,7 +310,7 @@ class OrderHistoryCore extends ObjectModel
return false;
$result = Db::getInstance()->getRow('
SELECT osl.`template`, c.`lastname`, c.`firstname`, osl.`name` AS osname, c.`email`
SELECT osl.`template`, c.`lastname`, c.`firstname`, osl.`name` AS osname, c.`email`, os.`module_name`
FROM `'._DB_PREFIX_.'order_history` oh
LEFT JOIN `'._DB_PREFIX_.'orders` o ON oh.`id_order` = o.`id_order`
LEFT JOIN `'._DB_PREFIX_.'customer` c ON o.`id_customer` = c.`id_customer`
@@ -328,6 +328,14 @@ class OrderHistoryCore extends ObjectModel
);
if ($template_vars)
$data = array_merge($data, $template_vars);
if ($result['module_name'])
{
$module = Module::getInstanceByName($result['module_name']);
if (Validate::isLoadedObject($module) && isset($module->extra_mail_vars) && is_array($module->extra_mail_vars))
$data = array_merge($data, $module->extra_mail_vars);
}
$data['{total_paid}'] = Tools::displayPrice((float)$order->total_paid, new Currency((int)$order->id_currency), false);
$data['{order_name}'] = $order->getUniqReference();
+3
View File
@@ -36,6 +36,8 @@ class OrderStateCore extends ObjectModel
/** @var boolean Send an e-mail to customer ? */
public $send_email;
public $module_name;
/** @var boolean Allow customer to view and download invoice when order is at this state */
public $invoice;
@@ -71,6 +73,7 @@ class OrderStateCore extends ObjectModel
'multilang' => true,
'fields' => array(
'send_email' => array('type' => self::TYPE_BOOL, 'validate' => 'isBool'),
'module_name' => array('type' => self::TYPE_STRING, 'validate' => 'isModuleName'),
'invoice' => array('type' => self::TYPE_BOOL, 'validate' => 'isBool'),
'color' => array('type' => self::TYPE_STRING, 'validate' => 'isColor'),
'logable' => array('type' => self::TYPE_BOOL, 'validate' => 'isBool'),
+4 -2
View File
@@ -1264,7 +1264,8 @@ CREATE TABLE `PREFIX_order_slip_detail` (
CREATE TABLE `PREFIX_order_state` (
`id_order_state` int(10) UNSIGNED NOT NULL auto_increment,
`invoice` tinyint(1) UNSIGNED default '0',
`send_email` tinyint(1) UNSIGNED NOT NULL default '0',
`send_email` tinyint(1) UNSIGNED NOT NULL default '0',
`module_name` VARCHAR(255) NULL DEFAULT NULL,
`color` varchar(32) default NULL,
`unremovable` tinyint(1) UNSIGNED NOT NULL,
`hidden` tinyint(1) UNSIGNED NOT NULL default '0',
@@ -1273,7 +1274,8 @@ CREATE TABLE `PREFIX_order_state` (
`shipped` tinyint(1) UNSIGNED NOT NULL default '0',
`paid` tinyint(1) UNSIGNED NOT NULL default '0',
`deleted` tinyint(1) UNSIGNED NOT NULL default '0',
PRIMARY KEY (`id_order_state`)
PRIMARY KEY (`id_order_state`),
KEY `module_name` (`module_name`)
) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8;
CREATE TABLE `PREFIX_order_state_lang` (
+3 -2
View File
@@ -3,6 +3,7 @@
<fields id="name" class="OrderState" image="os">
<field name="invoice"/>
<field name="send_email"/>
<field name="module_name"/>
<field name="color"/>
<field name="unremovable"/>
<field name="hidden"/>
@@ -12,7 +13,7 @@
<field name="paid"/>
</fields>
<entities>
<order_state id="Awaiting_cheque_payment" invoice="0" send_email="1" color="RoyalBlue" unremovable="1" hidden="0" logable="0" delivery="0" shipped="0" paid="0"/>
<order_state id="Awaiting_cheque_payment" invoice="0" send_email="1" module_name="cheque" color="RoyalBlue" unremovable="1" hidden="0" logable="0" delivery="0" shipped="0" paid="0"/>
<order_state id="Payment_accepted" invoice="1" send_email="1" color="LimeGreen" unremovable="1" hidden="0" logable="1" delivery="0" shipped="0" paid="1"/>
<order_state id="Preparation_in_progress" invoice="1" send_email="1" color="DarkOrange" unremovable="1" hidden="0" logable="1" delivery="1" shipped="0" paid="1"/>
<order_state id="Shipped" invoice="1" send_email="1" color="BlueViolet" unremovable="1" hidden="0" logable="1" delivery="1" shipped="1" paid="1"/>
@@ -21,7 +22,7 @@
<order_state id="Refund" invoice="1" send_email="1" color="#ec2e15" unremovable="1" hidden="0" logable="0" delivery="0" shipped="0" paid="0"/>
<order_state id="Payment_error" invoice="0" send_email="1" color="#8f0621" unremovable="1" hidden="0" logable="0" delivery="0" shipped="0" paid="0"/>
<order_state id="On_backorder" invoice="1" send_email="1" color="HotPink" unremovable="1" hidden="0" logable="0" delivery="0" shipped="0" paid="1"/>
<order_state id="Awaiting_bank_wire_payment" invoice="0" send_email="1" color="RoyalBlue" unremovable="1" hidden="0" logable="0" delivery="0" shipped="0" paid="0"/>
<order_state id="Awaiting_bank_wire_payment" invoice="0" send_email="1" module_name="bankwire" color="RoyalBlue" unremovable="1" hidden="0" logable="0" delivery="0" shipped="0" paid="0"/>
<order_state id="Awaiting_PayPal_payment" invoice="0" send_email="0" color="RoyalBlue" unremovable="1" hidden="0" logable="0" delivery="0" shipped="0" paid="0"/>
<order_state id="Payment_remotely_accepted" invoice="1" send_email="0" color="LimeGreen" unremovable="1" hidden="0" logable="1" delivery="0" shipped="0" paid="1"/>
</entities>
+5
View File
@@ -2,4 +2,9 @@ SET NAMES 'utf8';
/* PHP:p15015_blockadvertising_extension(); */;
ALTER TABLE `PREFIX_order_state` ADD `module_name` VARCHAR(255) NULL DEFAULT NULL AFTER `send_email`;
UPDATE `PREFIX_order_state` SET `module_name`='cheque' WHERE `id_order_state`=(SELECT `value` FROM `PREFIX_configuration` WHERE `name`='PS_OS_CHEQUE' LIMIT 1);
UPDATE `PREFIX_order_state` SET `module_name`='bankwire' WHERE `id_order_state`=(SELECT `value` FROM `PREFIX_configuration` WHERE `name`='PS_OS_BANKWIRE' LIMIT 1);
+7 -1
View File
@@ -36,7 +36,7 @@ class BankWire extends PaymentModule
public $details;
public $owner;
public $address;
public $extra_mail_vars;
public function __construct()
{
$this->name = 'bankwire';
@@ -64,6 +64,12 @@ class BankWire extends PaymentModule
$this->warning = $this->l('Account owner and details must be configured in order to use this module correctly.');
if (!count(Currency::checkPaymentCurrencies($this->id)))
$this->warning = $this->l('No currency set for this module');
$this->extra_mail_vars = array(
'{bankwire_owner}' => Configuration::get('BANK_WIRE_OWNER'),
'{bankwire_details}' => nl2br(Configuration::get('BANK_WIRE_DETAILS')),
'{bankwire_address}' => nl2br(Configuration::get('BANK_WIRE_ADDRESS'))
);
}
public function install()
+2 -6
View File
@@ -58,12 +58,8 @@ if (!Validate::isLoadedObject($customer))
$currency = $context->currency;
$total = (float)($cart->getOrderTotal(true, Cart::BOTH));
$mailVars = array(
'{bankwire_owner}' => Configuration::get('BANK_WIRE_OWNER'),
'{bankwire_details}' => nl2br(Configuration::get('BANK_WIRE_DETAILS')),
'{bankwire_address}' => nl2br(Configuration::get('BANK_WIRE_ADDRESS'))
);
$bankwire->validateOrder($cart->id, Configuration::get('PS_OS_BANKWIRE'), $total, $bankwire->displayName, NULL, $mailVars, (int)$currency->id, false, $customer->secure_key);
$bankwire->validateOrder($cart->id, Configuration::get('PS_OS_BANKWIRE'), $total, $bankwire->displayName, NULL, array(), (int)$currency->id, false, $customer->secure_key);
$order = new Order($bankwire->currentOrder);
Tools::redirect('index.php?controller=order-confirmation&id_cart='.$cart->id.'&id_module='.$bankwire->id.'&id_order='.$bankwire->currentOrder.'&key='.$customer->secure_key);
+7
View File
@@ -35,6 +35,7 @@ class Cheque extends PaymentModule
public $chequeName;
public $address;
public $extra_mail_vars;
public function __construct()
{
@@ -62,6 +63,12 @@ class Cheque extends PaymentModule
$this->warning = $this->l('\'To the order of\' and address must be configured in order to use this module correctly.');
if (!count(Currency::checkPaymentCurrencies($this->id)))
$this->warning = $this->l('No currency set for this module');
$this->extra_mail_vars = array(
'{cheque_name}' => Configuration::get('CHEQUE_NAME'),
'{cheque_address}' => Configuration::get('CHEQUE_ADDRESS'),
'{cheque_address_html}' => str_replace("\n", '<br />', Configuration::get('CHEQUE_ADDRESS'))
);
}
public function install()
+1 -6
View File
@@ -61,12 +61,7 @@ if (!Validate::isLoadedObject($customer))
$currency = $context->currency;
$total = (float)$cart->getOrderTotal(true, Cart::BOTH);
$mailVars = array(
'{cheque_name}' => Configuration::get('CHEQUE_NAME'),
'{cheque_address}' => Configuration::get('CHEQUE_ADDRESS'),
'{cheque_address_html}' => str_replace("\n", '<br />', Configuration::get('CHEQUE_ADDRESS')));
$cheque->validateOrder((int)$cart->id, Configuration::get('PS_OS_CHEQUE'), $total, $cheque->displayName, NULL, $mailVars, (int)$currency->id, false, $customer->secure_key);
$cheque->validateOrder((int)$cart->id, Configuration::get('PS_OS_CHEQUE'), $total, $cheque->displayName, NULL, array(), (int)$currency->id, false, $customer->secure_key);
Tools::redirect('index.php?controller=order-confirmation&id_cart='.(int)($cart->id).'&id_module='.(int)($cheque->id).'&id_order='.$cheque->currentOrder.'&key='.$customer->secure_key);