Version Notes
If you have ideas for improvements or find bugs, please send them to Franck Charpentier at www.auguria.net, with Auguria LastReviews as part of the subject line.
Download this release
Release Info
Developer | Magento Core Team |
Extension | Auguria_Sponsorship |
Version | 1.0.1 |
Comparing to | |
See all releases |
Version 1.0.1
- app/code/community/Auguria/Sponsorship/Block/Adminhtml/Change.php +19 -0
- app/code/community/Auguria/Sponsorship/Block/Adminhtml/Change/Edit.php +71 -0
- app/code/community/Auguria/Sponsorship/Block/Adminhtml/Change/Edit/Form.php +24 -0
- app/code/community/Auguria/Sponsorship/Block/Adminhtml/Change/Edit/Tab/Form.php +105 -0
- app/code/community/Auguria/Sponsorship/Block/Adminhtml/Change/Edit/Tabs.php +29 -0
- app/code/community/Auguria/Sponsorship/Block/Adminhtml/Change/Grid.php +176 -0
- app/code/community/Auguria/Sponsorship/Block/Adminhtml/Link.php +19 -0
- app/code/community/Auguria/Sponsorship/Block/Adminhtml/Link/Edit.php +71 -0
- app/code/community/Auguria/Sponsorship/Block/Adminhtml/Link/Edit/Form.php +24 -0
- app/code/community/Auguria/Sponsorship/Block/Adminhtml/Link/Edit/Tab/Form.php +37 -0
- app/code/community/Auguria/Sponsorship/Block/Adminhtml/Link/Edit/Tabs.php +29 -0
- app/code/community/Auguria/Sponsorship/Block/Adminhtml/Link/Grid.php +123 -0
- app/code/community/Auguria/Sponsorship/Block/Adminhtml/Sponsorship.php +21 -0
- app/code/community/Auguria/Sponsorship/Block/Adminhtml/Sponsorship/Edit.php +72 -0
- app/code/community/Auguria/Sponsorship/Block/Adminhtml/Sponsorship/Edit/Form.php +24 -0
- app/code/community/Auguria/Sponsorship/Block/Adminhtml/Sponsorship/Edit/Tab/Form.php +48 -0
- app/code/community/Auguria/Sponsorship/Block/Adminhtml/Sponsorship/Edit/Tabs.php +29 -0
- app/code/community/Auguria/Sponsorship/Block/Adminhtml/Sponsorship/Grid.php +122 -0
- app/code/community/Auguria/Sponsorship/Block/Customer/Account/PointsDetail.php +286 -0
- app/code/community/Auguria/Sponsorship/Block/Customer/Form/Boost.php +41 -0
- app/code/community/Auguria/Sponsorship/Block/Customer/Form/PointsChange.php +52 -0
- app/code/community/Auguria/Sponsorship/Block/Customer/Widget/Name.php +33 -0
- app/code/community/Auguria/Sponsorship/Block/Customer/Widget/Virement.php +42 -0
- app/code/community/Auguria/Sponsorship/Block/Promo/Catalog/Edit/Tab/Actions.php +69 -0
- app/code/community/Auguria/Sponsorship/Block/Promo/Quote/Edit/Tab/Actions.php +107 -0
- app/code/community/Auguria/Sponsorship/Block/Sponsorship.php +65 -0
- app/code/community/Auguria/Sponsorship/Helper/Data.php +67 -0
- app/code/community/Auguria/Sponsorship/Helper/Mail.php +267 -0
- app/code/community/Auguria/Sponsorship/Lib/Html2Text.php +397 -0
- app/code/community/Auguria/Sponsorship/Model/Adminhtml/System/Config/Backend/Sponsorship/Entier.php +25 -0
- app/code/community/Auguria/Sponsorship/Model/Adminhtml/System/Config/Backend/Sponsorship/Float.php +26 -0
- app/code/community/Auguria/Sponsorship/Model/AutoBoost.php +63 -0
- app/code/community/Auguria/Sponsorship/Model/Change.php +15 -0
- app/code/community/Auguria/Sponsorship/Model/Changestatut.php +24 -0
- app/code/community/Auguria/Sponsorship/Model/Core/Email/Template.php +68 -0
- app/code/community/Auguria/Sponsorship/Model/Customer/Customer.php +112 -0
- app/code/community/Auguria/Sponsorship/Model/EmptyPHP.php +266 -0
- app/code/community/Auguria/Sponsorship/Model/Fidelitylog.php +15 -0
- app/code/community/Auguria/Sponsorship/Model/Mysql4/CatalogFidelityPoint.php +15 -0
- app/code/community/Auguria/Sponsorship/Model/Mysql4/CatalogFidelityPoint/Collection.php +15 -0
- app/code/community/Auguria/Sponsorship/Model/Mysql4/CatalogSponsorPoint.php +15 -0
- app/code/community/Auguria/Sponsorship/Model/Mysql4/CatalogSponsorPoint/Collection.php +15 -0
- app/code/community/Auguria/Sponsorship/Model/Mysql4/Change.php +15 -0
- app/code/community/Auguria/Sponsorship/Model/Mysql4/Change/Collection.php +33 -0
- app/code/community/Auguria/Sponsorship/Model/Mysql4/FidelityLog/Collection.php +15 -0
- app/code/community/Auguria/Sponsorship/Model/Mysql4/Fidelitylog.php +15 -0
- app/code/community/Auguria/Sponsorship/Model/Mysql4/Rule.php +394 -0
- app/code/community/Auguria/Sponsorship/Model/Mysql4/Sponsorlog.php +15 -0
- app/code/community/Auguria/Sponsorship/Model/Mysql4/Sponsorlog/Collection.php +15 -0
- app/code/community/Auguria/Sponsorship/Model/Mysql4/Sponsorship.php +15 -0
- app/code/community/Auguria/Sponsorship/Model/Mysql4/Sponsorship/Collection.php +36 -0
- app/code/community/Auguria/Sponsorship/Model/Observer.php +334 -0
- app/code/community/Auguria/Sponsorship/Model/Sponsorlog.php +15 -0
- app/code/community/Auguria/Sponsorship/Model/Sponsorship.php +15 -0
- app/code/community/Auguria/Sponsorship/Model/Status.php +20 -0
- app/code/community/Auguria/Sponsorship/Model/Validator.php +253 -0
- app/code/community/Auguria/Sponsorship/controllers/Adminhtml/ChangeController.php +278 -0
- app/code/community/Auguria/Sponsorship/controllers/Adminhtml/LinkController.php +144 -0
- app/code/community/Auguria/Sponsorship/controllers/Adminhtml/SponsorshipController.php +144 -0
- app/code/community/Auguria/Sponsorship/controllers/BoostController.php +78 -0
- app/code/community/Auguria/Sponsorship/controllers/Customer/AccountController.php +222 -0
- app/code/community/Auguria/Sponsorship/controllers/FidelitypointsController.php +352 -0
- app/code/community/Auguria/Sponsorship/controllers/IndexController.php +108 -0
- app/code/community/Auguria/Sponsorship/controllers/SponsorController.php +49 -0
- app/code/community/Auguria/Sponsorship/controllers/SponsorpointsController.php +352 -0
- app/code/community/Auguria/Sponsorship/etc/config.xml +336 -0
- app/code/community/Auguria/Sponsorship/etc/system.xml +272 -0
- app/code/community/Auguria/Sponsorship/sql/sponsorship_setup/mysql4-install-0.1.0.php +41 -0
- app/code/community/Auguria/Sponsorship/sql/sponsorship_setup/mysql4-upgrade-0.1.0-0.1.1.php +68 -0
- app/code/community/Auguria/Sponsorship/sql/sponsorship_setup/mysql4-upgrade-0.1.1-0.1.2.php +52 -0
- app/code/community/Auguria/Sponsorship/sql/sponsorship_setup/mysql4-upgrade-0.1.2-0.1.3.php +87 -0
- app/code/community/Auguria/Sponsorship/sql/sponsorship_setup/mysql4-upgrade-0.1.3-0.1.4.php +40 -0
- app/code/community/Auguria/Sponsorship/sql/sponsorship_setup/mysql4-upgrade-0.1.4-0.1.5.php +49 -0
- app/code/community/Auguria/Sponsorship/sql/sponsorship_setup/mysql4-upgrade-0.1.5-0.1.6.php +39 -0
- app/code/community/Auguria/Sponsorship/sql/sponsorship_setup/mysql4-upgrade-0.1.6-0.1.7.php +18 -0
- app/code/community/Auguria/Sponsorship/sql/sponsorship_setup/mysql4-upgrade-0.1.7-0.1.8.php +49 -0
- app/code/community/Auguria/Sponsorship/sql/sponsorship_setup/mysql4-upgrade-0.1.8-0.1.9.php +22 -0
- app/code/community/Auguria/Sponsorship/sql/sponsorship_setup/mysql4-upgrade-0.1.9-0.1.10.php +30 -0
- app/design/adminhtml/default/default/layout/sponsorship.xml +26 -0
- app/design/frontend/default/default/layout/sponsorship.xml +122 -0
- app/design/frontend/default/default/template/sponsorship/customer/account/dashboard.phtml +53 -0
- app/design/frontend/default/default/template/sponsorship/customer/account/dashboard/fidelity_points.phtml +17 -0
- app/design/frontend/default/default/template/sponsorship/customer/account/dashboard/sponsor_points.phtml +23 -0
- app/design/frontend/default/default/template/sponsorship/customer/account/fidelitypointsdetail.phtml +167 -0
- app/design/frontend/default/default/template/sponsorship/customer/account/sponsorpointsdetail.phtml +257 -0
- app/design/frontend/default/default/template/sponsorship/customer/form/boost.phtml +86 -0
- app/design/frontend/default/default/template/sponsorship/customer/form/edit.phtml +120 -0
- app/design/frontend/default/default/template/sponsorship/customer/form/pointschange.phtml +34 -0
- app/design/frontend/default/default/template/sponsorship/customer/form/pointschange/pointschange_cash.phtml +65 -0
- app/design/frontend/default/default/template/sponsorship/customer/form/pointschange/pointschange_coupon.phtml +59 -0
- app/design/frontend/default/default/template/sponsorship/customer/form/pointschange/pointschange_gift.phtml +9 -0
- app/design/frontend/default/default/template/sponsorship/customer/form/register.phtml +174 -0
- app/design/frontend/default/default/template/sponsorship/customer/widget/name.phtml +176 -0
- app/design/frontend/default/default/template/sponsorship/customer/widget/virement.phtml +32 -0
- app/design/frontend/default/default/template/sponsorship/sponsorship.phtml +149 -0
- app/etc/modules/Auguria_Sponsorship.xml +17 -0
- app/locale/en_US/template/email/sponsorship_coupon.html +76 -0
- app/locale/en_US/template/email/sponsorship_invitation.html +60 -0
- app/locale/fr_FR/Auguria_Sponsorship.csv +184 -0
- app/locale/fr_FR/template/email/sponsorship_coupon.html +76 -0
- app/locale/fr_FR/template/email/sponsorship_invitation.html +60 -0
- js/tableorderer/table_orderer.js +574 -0
- package.xml +34 -0
- skin/frontend/default/default/css/tableorderer.css +74 -0
- skin/frontend/default/default/images/tableorderer/asc.gif +0 -0
- skin/frontend/default/default/images/tableorderer/bg.gif +0 -0
- skin/frontend/default/default/images/tableorderer/bkg_toolbar.gif +0 -0
- skin/frontend/default/default/images/tableorderer/desc.gif +0 -0
app/code/community/Auguria/Sponsorship/Block/Adminhtml/Change.php
ADDED
@@ -0,0 +1,19 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* @category Auguria
|
4 |
+
* @package Auguria_Sponsorship
|
5 |
+
* @author Auguria
|
6 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
7 |
+
*/
|
8 |
+
class Auguria_Sponsorship_Block_Adminhtml_Change extends Mage_Adminhtml_Block_Widget_Grid_Container
|
9 |
+
{
|
10 |
+
public function __construct()
|
11 |
+
{
|
12 |
+
Mage_Adminhtml_Block_Widget_Container::__construct();
|
13 |
+
$this->setTemplate('widget/grid/container.phtml');
|
14 |
+
$this->_controller = 'adminhtml_change';
|
15 |
+
$this->_blockGroup = 'sponsorship';
|
16 |
+
$this->_headerText = $this->__('Points exchanges list');
|
17 |
+
//$this->_addButtonLabel = $this->__('Ajouter un échange');
|
18 |
+
}
|
19 |
+
}
|
app/code/community/Auguria/Sponsorship/Block/Adminhtml/Change/Edit.php
ADDED
@@ -0,0 +1,71 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* @category Auguria
|
4 |
+
* @package Auguria_Sponsorship
|
5 |
+
* @author Auguria
|
6 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
7 |
+
*/
|
8 |
+
class Auguria_Sponsorship_Block_Adminhtml_Change_Edit extends Mage_Adminhtml_Block_Widget_Form_Container
|
9 |
+
{
|
10 |
+
public function __construct()
|
11 |
+
{
|
12 |
+
Mage_Adminhtml_Block_Widget_Container::__construct();
|
13 |
+
|
14 |
+
if (!$this->hasData('template')) {
|
15 |
+
$this->setTemplate('widget/form/container.phtml');
|
16 |
+
}
|
17 |
+
|
18 |
+
$this->_addButton('back', array(
|
19 |
+
'label' => Mage::helper('adminhtml')->__('Back'),
|
20 |
+
'onclick' => 'setLocation(\'' . $this->getBackUrl() . '\')',
|
21 |
+
'class' => 'back',
|
22 |
+
), -1);
|
23 |
+
$this->_addButton('reset', array(
|
24 |
+
'label' => Mage::helper('adminhtml')->__('Reset'),
|
25 |
+
'onclick' => 'setLocation(window.location.href)',
|
26 |
+
), -1);
|
27 |
+
|
28 |
+
$objId = $this->getRequest()->getParam($this->_objectId);
|
29 |
+
|
30 |
+
$this->_addButton('save', array(
|
31 |
+
'label' => Mage::helper('adminhtml')->__('Save'),
|
32 |
+
'onclick' => 'editForm.submit();',
|
33 |
+
'class' => 'save',
|
34 |
+
), 1);
|
35 |
+
|
36 |
+
$this->_objectId = 'id';
|
37 |
+
$this->_blockGroup = 'sponsorship';
|
38 |
+
$this->_controller = 'adminhtml_change';
|
39 |
+
$this->_updateButton('save', 'label', Mage::helper('adminhtml')->__('Save'));
|
40 |
+
$this->_updateButton('delete', 'label', Mage::helper('adminhtml')->__('Save'));
|
41 |
+
|
42 |
+
$this->_addButton('saveandcontinue', array(
|
43 |
+
'label' => Mage::helper('adminhtml')->__('Save And Continue Edit'),
|
44 |
+
'onclick' => 'saveAndContinueEdit()',
|
45 |
+
'class' => 'save',
|
46 |
+
), -100);
|
47 |
+
|
48 |
+
$this->_formScripts[] = "
|
49 |
+
function toggleEditor() {
|
50 |
+
if (tinyMCE.getInstanceById('change_content') == null) {
|
51 |
+
tinyMCE.execCommand('mceAddControl', false, 'change_content');
|
52 |
+
} else {
|
53 |
+
tinyMCE.execCommand('mceRemoveControl', false, 'change_content');
|
54 |
+
}
|
55 |
+
}
|
56 |
+
|
57 |
+
function saveAndContinueEdit(){
|
58 |
+
editForm.submit($('edit_form').action+'back/edit/');
|
59 |
+
}
|
60 |
+
";
|
61 |
+
}
|
62 |
+
|
63 |
+
public function getHeaderText()
|
64 |
+
{
|
65 |
+
if( Mage::registry('change_data') && Mage::registry('change_data')->getId() ) {
|
66 |
+
return Mage::helper('sponsorship')->__("Edition of the change '%s'", $this->htmlEscape(Mage::registry('change_data')->getId()));
|
67 |
+
} else {
|
68 |
+
return Mage::helper('sponsorship')->__('Add a change');
|
69 |
+
}
|
70 |
+
}
|
71 |
+
}
|
app/code/community/Auguria/Sponsorship/Block/Adminhtml/Change/Edit/Form.php
ADDED
@@ -0,0 +1,24 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* @category Auguria
|
4 |
+
* @package Auguria_Sponsorship
|
5 |
+
* @author Auguria
|
6 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
7 |
+
*/
|
8 |
+
class Auguria_Sponsorship_Block_Adminhtml_Change_Edit_Form extends Mage_Adminhtml_Block_Widget_Form
|
9 |
+
{
|
10 |
+
protected function _prepareForm()
|
11 |
+
{
|
12 |
+
$form = new Varien_Data_Form(array(
|
13 |
+
'id' => 'edit_form',
|
14 |
+
'action' => $this->getUrl('*/*/save', array('id' => $this->getRequest()->getParam('id'))),
|
15 |
+
'method' => 'post',
|
16 |
+
'enctype' => 'multipart/form-data'
|
17 |
+
)
|
18 |
+
);
|
19 |
+
|
20 |
+
$form->setUseContainer(true);
|
21 |
+
$this->setForm($form);
|
22 |
+
return parent::_prepareForm();
|
23 |
+
}
|
24 |
+
}
|
app/code/community/Auguria/Sponsorship/Block/Adminhtml/Change/Edit/Tab/Form.php
ADDED
@@ -0,0 +1,105 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* @category Auguria
|
4 |
+
* @package Auguria_Sponsorship
|
5 |
+
* @author Auguria
|
6 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
7 |
+
*/
|
8 |
+
class Auguria_Sponsorship_Block_Adminhtml_Change_Edit_Tab_Form extends Mage_Adminhtml_Block_Widget_Form
|
9 |
+
{
|
10 |
+
protected function _prepareForm()
|
11 |
+
{
|
12 |
+
$form = new Varien_Data_Form();
|
13 |
+
$this->setForm($form);
|
14 |
+
$fieldset = $form->addFieldset('change_form', array('legend'=>Mage::helper('sponsorship')->__('Change information')));
|
15 |
+
|
16 |
+
$fieldset->addField('customer_id', 'text', array(
|
17 |
+
'label' => Mage::helper('sponsorship')->__('Customer'),
|
18 |
+
'class' => 'required-entry',
|
19 |
+
'required' => true,
|
20 |
+
'name' => 'customer_id',
|
21 |
+
))->setReadonly(true, true);
|
22 |
+
|
23 |
+
$fieldset->addField('type', 'select', array(
|
24 |
+
'label' => Mage::helper('sponsorship')->__('Type'),
|
25 |
+
'required' => true,
|
26 |
+
'name' => 'type',
|
27 |
+
'values' => array(
|
28 |
+
array(
|
29 |
+
'value' => 'cash',
|
30 |
+
'label' => Mage::helper('sponsorship')->__('Cash'),
|
31 |
+
),
|
32 |
+
|
33 |
+
array(
|
34 |
+
'value' => 'gift',
|
35 |
+
'label' => Mage::helper('sponsorship')->__('Gifts'),
|
36 |
+
),
|
37 |
+
array(
|
38 |
+
'value' => 'coupon',
|
39 |
+
'label' => Mage::helper('sponsorship')->__('Vouchers'),
|
40 |
+
),
|
41 |
+
),
|
42 |
+
))->setReadonly(true, true);
|
43 |
+
|
44 |
+
$fieldset->addField('module', 'select', array(
|
45 |
+
'label' => Mage::helper('sponsorship')->__('Module'),
|
46 |
+
'required' => true,
|
47 |
+
'name' => 'module',
|
48 |
+
'values' => array(
|
49 |
+
array(
|
50 |
+
'value' => 'fidelity',
|
51 |
+
'label' => Mage::helper('sponsorship')->__('Fidelity'),
|
52 |
+
),
|
53 |
+
|
54 |
+
array(
|
55 |
+
'value' => 'sponsor',
|
56 |
+
'label' => Mage::helper('sponsorship')->__('Sponsorship'),
|
57 |
+
),
|
58 |
+
),
|
59 |
+
))->setReadonly(true, true);
|
60 |
+
|
61 |
+
$fieldset->addField('statut', 'select', array(
|
62 |
+
'label' => Mage::helper('sponsorship')->__('Status'),
|
63 |
+
'name' => 'statut',
|
64 |
+
'values' => array(
|
65 |
+
array(
|
66 |
+
'value' => 'waiting',
|
67 |
+
'label' => Mage::helper('sponsorship')->__('Waiting'),
|
68 |
+
),
|
69 |
+
|
70 |
+
array(
|
71 |
+
'value' => 'exported',
|
72 |
+
'label' => Mage::helper('sponsorship')->__('Exported'),
|
73 |
+
),
|
74 |
+
array(
|
75 |
+
'value' => 'solved',
|
76 |
+
'label' => Mage::helper('sponsorship')->__('Solved'),
|
77 |
+
),
|
78 |
+
|
79 |
+
array(
|
80 |
+
'value' => 'canceled',
|
81 |
+
'label' => Mage::helper('sponsorship')->__('Canceled'),
|
82 |
+
),
|
83 |
+
),
|
84 |
+
));
|
85 |
+
|
86 |
+
$fieldset->addField('datetime', 'date', array(
|
87 |
+
'label' => Mage::helper('sponsorship')->__('Creation date'),
|
88 |
+
'title' => Mage::helper('sponsorship')->__('Creation date'),
|
89 |
+
'required' => true,
|
90 |
+
'name' => 'datetime',
|
91 |
+
'image' => Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_SKIN).'/adminhtml/default/default/images/grid-cal.gif',
|
92 |
+
'input_format' => Mage::app()->getLocale()->getDateTimeFormat(Mage_Core_Model_Locale::FORMAT_TYPE_SHORT),
|
93 |
+
'format' => Mage::app()->getLocale()->getDateTimeFormat(Mage_Core_Model_Locale::FORMAT_TYPE_SHORT),
|
94 |
+
))->setReadonly(true, true);
|
95 |
+
|
96 |
+
if ( Mage::getSingleton('adminhtml/session')->getSponsorshipData() )
|
97 |
+
{
|
98 |
+
$form->setValues(Mage::getSingleton('adminhtml/session')->getSponsorshipData());
|
99 |
+
Mage::getSingleton('adminhtml/session')->setSponsorshipData(null);
|
100 |
+
} elseif ( Mage::registry('change_data') ) {
|
101 |
+
$form->setValues(Mage::registry('change_data')->getData());
|
102 |
+
}
|
103 |
+
return parent::_prepareForm();
|
104 |
+
}
|
105 |
+
}
|
app/code/community/Auguria/Sponsorship/Block/Adminhtml/Change/Edit/Tabs.php
ADDED
@@ -0,0 +1,29 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* @category Auguria
|
4 |
+
* @package Auguria_Sponsorship
|
5 |
+
* @author Auguria
|
6 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
7 |
+
*/
|
8 |
+
class Auguria_Sponsorship_Block_Adminhtml_Change_Edit_Tabs extends Mage_Adminhtml_Block_Widget_Tabs
|
9 |
+
{
|
10 |
+
|
11 |
+
public function __construct()
|
12 |
+
{
|
13 |
+
parent::__construct();
|
14 |
+
$this->setId('change_tabs');
|
15 |
+
$this->setDestElementId('edit_form');
|
16 |
+
$this->setTitle(Mage::helper('sponsorship')->__('Exchange detail'));
|
17 |
+
}
|
18 |
+
|
19 |
+
protected function _beforeToHtml()
|
20 |
+
{
|
21 |
+
$this->addTab('form_section', array(
|
22 |
+
'label' => Mage::helper('sponsorship')->__('Exchange detail'),
|
23 |
+
'title' => Mage::helper('sponsorship')->__('Exchange detail'),
|
24 |
+
'content' => $this->getLayout()->createBlock('sponsorship/adminhtml_change_edit_tab_form')->toHtml(),
|
25 |
+
));
|
26 |
+
|
27 |
+
return parent::_beforeToHtml();
|
28 |
+
}
|
29 |
+
}
|
app/code/community/Auguria/Sponsorship/Block/Adminhtml/Change/Grid.php
ADDED
@@ -0,0 +1,176 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* @category Auguria
|
4 |
+
* @package Auguria_Sponsorship
|
5 |
+
* @author Auguria
|
6 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
7 |
+
*/
|
8 |
+
class Auguria_Sponsorship_Block_Adminhtml_Change_Grid extends Mage_Adminhtml_Block_Widget_Grid
|
9 |
+
{
|
10 |
+
public function __construct()
|
11 |
+
{
|
12 |
+
parent::__construct();
|
13 |
+
$this->setId('changeGrid');
|
14 |
+
$this->setDefaultSort('sponsorship_change_id');
|
15 |
+
$this->setDefaultDir('ASC');
|
16 |
+
$this->setSaveParametersInSession(true);
|
17 |
+
}
|
18 |
+
|
19 |
+
protected function _prepareCollection()
|
20 |
+
{
|
21 |
+
$collection = Mage::getResourceModel('sponsorship/change_collection')
|
22 |
+
->addNameToSelect()
|
23 |
+
;
|
24 |
+
/*
|
25 |
+
$collection = Mage::getModel('sponsorship/change')->getCollection();
|
26 |
+
foreach ($collection as $change)
|
27 |
+
{
|
28 |
+
$customer = mage::getModel("customer/customer")->load($change->getCustomerId());
|
29 |
+
$change->setCustomerName($customer->getFirstname()." ".$customer->getLastname());
|
30 |
+
$change->setValue(sprintf('%.2f',($change->getValue())));
|
31 |
+
$change->setPoints(floor($change->getPoints()));
|
32 |
+
}*/
|
33 |
+
$this->setCollection($collection);
|
34 |
+
return parent::_prepareCollection();
|
35 |
+
}
|
36 |
+
|
37 |
+
protected function _prepareColumns()
|
38 |
+
{
|
39 |
+
$this->addColumn('sponsorship_change_id', array(
|
40 |
+
'header' => Mage::helper('sponsorship')->__('ID'),
|
41 |
+
'align' =>'right',
|
42 |
+
'width' => '20px',
|
43 |
+
'index' => 'sponsorship_change_id',
|
44 |
+
));
|
45 |
+
|
46 |
+
$this->addColumn('customer_id', array(
|
47 |
+
'header' => Mage::helper('sponsorship')->__('Customer ID'),
|
48 |
+
'align' =>'right',
|
49 |
+
'width' => '20px',
|
50 |
+
'index' => 'customer_id',
|
51 |
+
));
|
52 |
+
|
53 |
+
$this->addColumn('customer_name', array(
|
54 |
+
'header' => Mage::helper('sponsorship')->__('Customer name'),
|
55 |
+
'align' =>'left',
|
56 |
+
'filter' => false,
|
57 |
+
'index' => 'customer_name',
|
58 |
+
));
|
59 |
+
|
60 |
+
|
61 |
+
$this->addColumn('type', array(
|
62 |
+
'header' => Mage::helper('sponsorship')->__('Type'),
|
63 |
+
'index' => 'type',
|
64 |
+
'type' => 'options',
|
65 |
+
'options' => array(
|
66 |
+
'cash' => 'Cash',
|
67 |
+
'gift' => 'Cadeaux',
|
68 |
+
'coupon' => 'Bons de réductions',
|
69 |
+
),
|
70 |
+
));
|
71 |
+
|
72 |
+
$this->addColumn('module', array(
|
73 |
+
'header' => Mage::helper('sponsorship')->__('Module'),
|
74 |
+
'index' => 'module',
|
75 |
+
'type' => 'options',
|
76 |
+
'options' => array(
|
77 |
+
'fidelity' => 'Fidélité',
|
78 |
+
'sponsor' => 'Parrainage',
|
79 |
+
),
|
80 |
+
));
|
81 |
+
|
82 |
+
$this->addColumn('points', array(
|
83 |
+
'header' => Mage::helper('sponsorship')->__('Points'),
|
84 |
+
'align' =>'right',
|
85 |
+
'index' => 'points',
|
86 |
+
));
|
87 |
+
|
88 |
+
$this->addColumn('value', array(
|
89 |
+
'header' => Mage::helper('sponsorship')->__('Value'),
|
90 |
+
'align' =>'right',
|
91 |
+
'index' => 'value',
|
92 |
+
));
|
93 |
+
|
94 |
+
$this->addColumn('datetime', array(
|
95 |
+
'header' => Mage::helper('sponsorship')->__('Date'),
|
96 |
+
'align' =>'right',
|
97 |
+
'index' => 'datetime',
|
98 |
+
'type' => 'datetime',
|
99 |
+
'format' => Mage::app()->getLocale()->getDateTimeFormat(Mage_Core_Model_Locale::FORMAT_TYPE_SHORT),
|
100 |
+
));
|
101 |
+
|
102 |
+
$this->addColumn('statut', array(
|
103 |
+
'header' => Mage::helper('sponsorship')->__('Status'),
|
104 |
+
'align' => 'left',
|
105 |
+
'index' => 'statut',
|
106 |
+
'type' => 'options',
|
107 |
+
'options' => array(
|
108 |
+
'waiting' => 'En attente',
|
109 |
+
'exported' => 'Exporté',
|
110 |
+
'solved' => 'Réglé',
|
111 |
+
'canceled' => 'Annulé',
|
112 |
+
),
|
113 |
+
));
|
114 |
+
|
115 |
+
$this->addColumn('action',
|
116 |
+
array(
|
117 |
+
'header' => Mage::helper('sponsorship')->__('Action'),
|
118 |
+
'width' => '100',
|
119 |
+
'type' => 'action',
|
120 |
+
'getter' => 'getId',
|
121 |
+
'actions' => array(
|
122 |
+
array(
|
123 |
+
'caption' => Mage::helper('sponsorship')->__('Edit'),
|
124 |
+
'url' => array('base'=> '*/*/edit'),
|
125 |
+
'field' => 'id'
|
126 |
+
)
|
127 |
+
),
|
128 |
+
'filter' => false,
|
129 |
+
'sortable' => false,
|
130 |
+
'index' => 'stores',
|
131 |
+
'is_system' => true,
|
132 |
+
));
|
133 |
+
|
134 |
+
$this->addExportType('*/*/exportCsv', Mage::helper('sponsorship')->__('CSV'));
|
135 |
+
$this->addExportType('*/*/exportXml', Mage::helper('sponsorship')->__('XML'));
|
136 |
+
|
137 |
+
return parent::_prepareColumns();
|
138 |
+
}
|
139 |
+
|
140 |
+
protected function _prepareMassaction()
|
141 |
+
{
|
142 |
+
$this->setMassactionIdField('change_id');
|
143 |
+
$this->getMassactionBlock()->setFormFieldName('change');
|
144 |
+
|
145 |
+
// $this->getMassactionBlock()->addItem('delete', array(
|
146 |
+
// 'label' => Mage::helper('sponsorship')->__('Delete'),
|
147 |
+
// 'url' => $this->getUrl('*/*/massDelete'),
|
148 |
+
// 'confirm' => Mage::helper('sponsorship')->__('Are you sure?')
|
149 |
+
// ));
|
150 |
+
|
151 |
+
$statuses = Mage::getSingleton('sponsorship/changestatut')->getOptionArray();
|
152 |
+
|
153 |
+
array_unshift($statuses, array('label'=>'', 'value'=>''));
|
154 |
+
$this->getMassactionBlock()->addItem('statut', array(
|
155 |
+
'label'=> Mage::helper('sponsorship')->__('Update status'),
|
156 |
+
'url' => $this->getUrl('*/*/massStatus', array('_current'=>true)),
|
157 |
+
'confirm' => Mage::helper('sponsorship')->__('Are you sure to process mass action?'),
|
158 |
+
'additional' => array(
|
159 |
+
'visibility' => array(
|
160 |
+
'name' => 'statut',
|
161 |
+
'type' => 'select',
|
162 |
+
'class' => 'required-entry',
|
163 |
+
'label' => Mage::helper('sponsorship')->__('Status'),
|
164 |
+
'values' => $statuses
|
165 |
+
)
|
166 |
+
)
|
167 |
+
));
|
168 |
+
return $this;
|
169 |
+
}
|
170 |
+
|
171 |
+
public function getRowUrl($row)
|
172 |
+
{
|
173 |
+
return $this->getUrl('*/*/edit', array('id' => $row->getId()));
|
174 |
+
}
|
175 |
+
|
176 |
+
}
|
app/code/community/Auguria/Sponsorship/Block/Adminhtml/Link.php
ADDED
@@ -0,0 +1,19 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* @category Auguria
|
4 |
+
* @package Auguria_Sponsorship
|
5 |
+
* @author Auguria
|
6 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
7 |
+
*/
|
8 |
+
class Auguria_Sponsorship_Block_Adminhtml_Link extends Mage_Adminhtml_Block_Widget_Grid_Container
|
9 |
+
{
|
10 |
+
public function __construct()
|
11 |
+
{
|
12 |
+
Mage_Adminhtml_Block_Widget_Container::__construct();
|
13 |
+
$this->setTemplate('widget/grid/container.phtml');
|
14 |
+
$this->_controller = 'adminhtml_link';
|
15 |
+
$this->_blockGroup = 'sponsorship';
|
16 |
+
$this->_headerText = $this->__('Sponsorships list');
|
17 |
+
//$this->_addButtonLabel = $this->__('Ajouter un échange');
|
18 |
+
}
|
19 |
+
}
|
app/code/community/Auguria/Sponsorship/Block/Adminhtml/Link/Edit.php
ADDED
@@ -0,0 +1,71 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* @category Auguria
|
4 |
+
* @package Auguria_Sponsorship
|
5 |
+
* @author Auguria
|
6 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
7 |
+
*/
|
8 |
+
class Auguria_Sponsorship_Block_Adminhtml_Link_Edit extends Mage_Adminhtml_Block_Widget_Form_Container
|
9 |
+
{
|
10 |
+
public function __construct()
|
11 |
+
{
|
12 |
+
Mage_Adminhtml_Block_Widget_Container::__construct();
|
13 |
+
|
14 |
+
if (!$this->hasData('template')) {
|
15 |
+
$this->setTemplate('widget/form/container.phtml');
|
16 |
+
}
|
17 |
+
|
18 |
+
$this->_addButton('back', array(
|
19 |
+
'label' => Mage::helper('adminhtml')->__('Back'),
|
20 |
+
'onclick' => 'setLocation(\'' . $this->getBackUrl() . '\')',
|
21 |
+
'class' => 'back',
|
22 |
+
), -1);
|
23 |
+
$this->_addButton('reset', array(
|
24 |
+
'label' => Mage::helper('adminhtml')->__('Reset'),
|
25 |
+
'onclick' => 'setLocation(window.location.href)',
|
26 |
+
), -1);
|
27 |
+
|
28 |
+
$objId = $this->getRequest()->getParam($this->_objectId);
|
29 |
+
|
30 |
+
$this->_addButton('save', array(
|
31 |
+
'label' => Mage::helper('adminhtml')->__('Save'),
|
32 |
+
'onclick' => 'editForm.submit();',
|
33 |
+
'class' => 'save',
|
34 |
+
), 1);
|
35 |
+
|
36 |
+
$this->_objectId = 'id';
|
37 |
+
$this->_blockGroup = 'sponsorship';
|
38 |
+
$this->_controller = 'adminhtml_link';
|
39 |
+
$this->_updateButton('save', 'label', Mage::helper('adminhtml')->__('Save'));
|
40 |
+
$this->_updateButton('delete', 'label', Mage::helper('adminhtml')->__('Delete'));
|
41 |
+
|
42 |
+
$this->_addButton('saveandcontinue', array(
|
43 |
+
'label' => Mage::helper('adminhtml')->__('Save And Continue Edit'),
|
44 |
+
'onclick' => 'saveAndContinueEdit()',
|
45 |
+
'class' => 'save',
|
46 |
+
), -100);
|
47 |
+
|
48 |
+
$this->_formScripts[] = "
|
49 |
+
function toggleEditor() {
|
50 |
+
if (tinyMCE.getInstanceById('link_content') == null) {
|
51 |
+
tinyMCE.execCommand('mceAddControl', false, 'link_content');
|
52 |
+
} else {
|
53 |
+
tinyMCE.execCommand('mceRemoveControl', false, 'link_content');
|
54 |
+
}
|
55 |
+
}
|
56 |
+
|
57 |
+
function saveAndContinueEdit(){
|
58 |
+
editForm.submit($('edit_form').action+'back/edit/');
|
59 |
+
}
|
60 |
+
";
|
61 |
+
}
|
62 |
+
|
63 |
+
public function getHeaderText()
|
64 |
+
{
|
65 |
+
if( Mage::registry('link_data') && Mage::registry('link_data')->getId() ) {
|
66 |
+
return Mage::helper('sponsorship')->__("Edition of the sponsorship '%s'", $this->htmlEscape(Mage::registry('link_data')->getId()));
|
67 |
+
} else {
|
68 |
+
return Mage::helper('sponsorship')->__('Add a sponsorship');
|
69 |
+
}
|
70 |
+
}
|
71 |
+
}
|
app/code/community/Auguria/Sponsorship/Block/Adminhtml/Link/Edit/Form.php
ADDED
@@ -0,0 +1,24 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* @category Auguria
|
4 |
+
* @package Auguria_Sponsorship
|
5 |
+
* @author Auguria
|
6 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
7 |
+
*/
|
8 |
+
class Auguria_Sponsorship_Block_Adminhtml_Link_Edit_Form extends Mage_Adminhtml_Block_Widget_Form
|
9 |
+
{
|
10 |
+
protected function _prepareForm()
|
11 |
+
{
|
12 |
+
$form = new Varien_Data_Form(array(
|
13 |
+
'id' => 'edit_form',
|
14 |
+
'action' => $this->getUrl('*/*/save', array('id' => $this->getRequest()->getParam('id'))),
|
15 |
+
'method' => 'post',
|
16 |
+
'enctype' => 'multipart/form-data'
|
17 |
+
)
|
18 |
+
);
|
19 |
+
|
20 |
+
$form->setUseContainer(true);
|
21 |
+
$this->setForm($form);
|
22 |
+
return parent::_prepareForm();
|
23 |
+
}
|
24 |
+
}
|
app/code/community/Auguria/Sponsorship/Block/Adminhtml/Link/Edit/Tab/Form.php
ADDED
@@ -0,0 +1,37 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* @category Auguria
|
4 |
+
* @package Auguria_Sponsorship
|
5 |
+
* @author Auguria
|
6 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
7 |
+
*/
|
8 |
+
class Auguria_Sponsorship_Block_Adminhtml_Link_Edit_Tab_Form extends Mage_Adminhtml_Block_Widget_Form
|
9 |
+
{
|
10 |
+
protected function _prepareForm()
|
11 |
+
{
|
12 |
+
$form = new Varien_Data_Form();
|
13 |
+
$this->setForm($form);
|
14 |
+
$fieldset = $form->addFieldset('link_form', array('legend'=>Mage::helper('sponsorship')->__('Sponsorship information')));
|
15 |
+
|
16 |
+
$fieldset->addField('entity_id', 'text', array(
|
17 |
+
'label' => Mage::helper('sponsorship')->__('Godson'),
|
18 |
+
'class' => 'required-entry',
|
19 |
+
'required' => true,
|
20 |
+
'name' => 'entity_id',
|
21 |
+
))->setReadonly(true);
|
22 |
+
|
23 |
+
$fieldset->addField('sponsor', 'text', array(
|
24 |
+
'label' => Mage::helper('sponsorship')->__('Sponsor'),
|
25 |
+
'name' => 'sponsor',
|
26 |
+
));
|
27 |
+
|
28 |
+
if ( Mage::getSingleton('adminhtml/session')->getSponsorshipData() )
|
29 |
+
{
|
30 |
+
$form->setValues(Mage::getSingleton('adminhtml/session')->getSponsorshipData());
|
31 |
+
Mage::getSingleton('adminhtml/session')->setSponsorshipData(null);
|
32 |
+
} elseif ( Mage::registry('link_data') ) {
|
33 |
+
$form->setValues(Mage::registry('link_data')->getData());
|
34 |
+
}
|
35 |
+
return parent::_prepareForm();
|
36 |
+
}
|
37 |
+
}
|
app/code/community/Auguria/Sponsorship/Block/Adminhtml/Link/Edit/Tabs.php
ADDED
@@ -0,0 +1,29 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* @category Auguria
|
4 |
+
* @package Auguria_Sponsorship
|
5 |
+
* @author Auguria
|
6 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
7 |
+
*/
|
8 |
+
class Auguria_Sponsorship_Block_Adminhtml_Link_Edit_Tabs extends Mage_Adminhtml_Block_Widget_Tabs
|
9 |
+
{
|
10 |
+
|
11 |
+
public function __construct()
|
12 |
+
{
|
13 |
+
parent::__construct();
|
14 |
+
$this->setId('link_tabs');
|
15 |
+
$this->setDestElementId('edit_form');
|
16 |
+
$this->setTitle(Mage::helper('sponsorship')->__('Sponsorship detail'));
|
17 |
+
}
|
18 |
+
|
19 |
+
protected function _beforeToHtml()
|
20 |
+
{
|
21 |
+
$this->addTab('form_section', array(
|
22 |
+
'label' => Mage::helper('sponsorship')->__('Sponsorship detail'),
|
23 |
+
'title' => Mage::helper('sponsorship')->__('Sponsorship detail'),
|
24 |
+
'content' => $this->getLayout()->createBlock('sponsorship/adminhtml_link_edit_tab_form')->toHtml(),
|
25 |
+
));
|
26 |
+
|
27 |
+
return parent::_beforeToHtml();
|
28 |
+
}
|
29 |
+
}
|
app/code/community/Auguria/Sponsorship/Block/Adminhtml/Link/Grid.php
ADDED
@@ -0,0 +1,123 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* @category Auguria
|
4 |
+
* @package Auguria_Sponsorship
|
5 |
+
* @author Auguria
|
6 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
7 |
+
*/
|
8 |
+
class Auguria_Sponsorship_Block_Adminhtml_Link_Grid extends Mage_Adminhtml_Block_Widget_Grid
|
9 |
+
{
|
10 |
+
public function __construct()
|
11 |
+
{
|
12 |
+
parent::__construct();
|
13 |
+
$this->setId('linkGrid');
|
14 |
+
$this->setDefaultSort('id_parrain');
|
15 |
+
$this->setDefaultDir('ASC');
|
16 |
+
$this->setSaveParametersInSession(true);
|
17 |
+
}
|
18 |
+
|
19 |
+
protected function _prepareCollection()
|
20 |
+
{
|
21 |
+
$customer = Mage::getModel('customer/customer');
|
22 |
+
$firstname = $customer->getAttribute('firstname');
|
23 |
+
$lastname = $customer->getAttribute('lastname');
|
24 |
+
$core = Mage::getSingleton('core/resource');
|
25 |
+
|
26 |
+
$collection = Mage::getResourceModel('customer/customer_collection')
|
27 |
+
->addAttributeToSelect("sponsor")
|
28 |
+
->addNameToSelect()
|
29 |
+
->addExpressionAttributeToSelect('sponsor_name',
|
30 |
+
new Zend_Db_Expr('CONCAT((select cev.value from '.$core->getTableName('customer_entity_varchar').' cev where cev.entity_id={{sponsor}} and cev.attribute_id='.(int) $firstname->getAttributeId().')," ",(select cev.value from '.$core->getTableName('customer_entity_varchar').' cev where cev.entity_id={{sponsor}} and cev.attribute_id='.(int) $lastname->getAttributeId().'))'),
|
31 |
+
'sponsor')
|
32 |
+
->addExpressionAttributeToSelect('date_last_order',
|
33 |
+
new Zend_Db_Expr('(select max(so.created_at) from '.$core->getTableName('sales_order').' so where so.customer_id={{entity_id}})'),
|
34 |
+
'entity_id')
|
35 |
+
->addAttributeToFilter("sponsor", array('neq'=> array(0)))
|
36 |
+
;
|
37 |
+
|
38 |
+
$this->setCollection($collection);
|
39 |
+
return parent::_prepareCollection();
|
40 |
+
}
|
41 |
+
|
42 |
+
protected function _prepareColumns()
|
43 |
+
{
|
44 |
+
$this->addColumn('id', array(
|
45 |
+
'header' => Mage::helper('sponsorship')->__('ID'),
|
46 |
+
'align' =>'right',
|
47 |
+
'width' =>'20px',
|
48 |
+
'index' => 'entity_id',
|
49 |
+
));
|
50 |
+
|
51 |
+
$this->addColumn('id_parrain', array(
|
52 |
+
'header' => Mage::helper('sponsorship')->__('Sponsor ID'),
|
53 |
+
'align' =>'right',
|
54 |
+
'width' =>'20px',
|
55 |
+
'index' => 'sponsor',
|
56 |
+
));
|
57 |
+
|
58 |
+
$this->addColumn('parrain', array(
|
59 |
+
'header' => Mage::helper('sponsorship')->__('Sponsor'),
|
60 |
+
'align' =>'left',
|
61 |
+
'index' => 'sponsor_name',
|
62 |
+
));
|
63 |
+
|
64 |
+
$this->addColumn('id_filleul', array(
|
65 |
+
'header' => Mage::helper('sponsorship')->__('Godson ID'),
|
66 |
+
'align' =>'right',
|
67 |
+
'width' =>'20px',
|
68 |
+
'index' => 'entity_id',
|
69 |
+
));
|
70 |
+
|
71 |
+
$this->addColumn('filleul', array(
|
72 |
+
'header' => Mage::helper('sponsorship')->__('Godson'),
|
73 |
+
'align' =>'left',
|
74 |
+
'index' => 'name',
|
75 |
+
));
|
76 |
+
|
77 |
+
$this->addColumn('date_inscription', array(
|
78 |
+
'header' => Mage::helper('sponsorship')->__('Listing date'),
|
79 |
+
'align' =>'left',
|
80 |
+
'align' =>'right',
|
81 |
+
'index' => 'created_at',
|
82 |
+
'type' => 'datetime',
|
83 |
+
'format' => Mage::app()->getLocale()->getDateTimeFormat(Mage_Core_Model_Locale::FORMAT_TYPE_SHORT),
|
84 |
+
));
|
85 |
+
|
86 |
+
$this->addColumn('date_last_order', array(
|
87 |
+
'header' => Mage::helper('sponsorship')->__('Last order date'),
|
88 |
+
'align' =>'left',
|
89 |
+
'align' =>'right',
|
90 |
+
'index' => 'date_last_order',
|
91 |
+
'type' => 'datetime',
|
92 |
+
'format' => Mage::app()->getLocale()->getDateTimeFormat(Mage_Core_Model_Locale::FORMAT_TYPE_SHORT),
|
93 |
+
));
|
94 |
+
|
95 |
+
$this->addExportType('*/*/exportCsv', Mage::helper('sponsorship')->__('CSV'));
|
96 |
+
$this->addExportType('*/*/exportXml', Mage::helper('sponsorship')->__('XML'));
|
97 |
+
|
98 |
+
return parent::_prepareColumns();
|
99 |
+
}
|
100 |
+
|
101 |
+
protected function _prepareMassaction()
|
102 |
+
{
|
103 |
+
$this->setMassactionIdField('id_filleul');
|
104 |
+
$this->getMassactionBlock()->setFormFieldName('sponsorship');
|
105 |
+
|
106 |
+
$statuses = Mage::getSingleton('sponsorship/changestatut')->getOptionArray();
|
107 |
+
|
108 |
+
array_unshift($statuses, array('label'=>'', 'value'=>''));
|
109 |
+
$this->getMassactionBlock()->addItem('sponsor', array(
|
110 |
+
'label'=> Mage::helper('sponsorship')->__('Supprimer Parrainages'),
|
111 |
+
'url' => $this->getUrl('*/*/massDelete', array('_current'=>true)),
|
112 |
+
'confirm' => Mage::helper('sponsorship')->__('Are you sure to process mass action?')
|
113 |
+
)
|
114 |
+
);
|
115 |
+
return $this;
|
116 |
+
}
|
117 |
+
|
118 |
+
public function getRowUrl($row)
|
119 |
+
{
|
120 |
+
return $this->getUrl('*/*/edit', array('id' => $row->getId()));
|
121 |
+
}
|
122 |
+
|
123 |
+
}
|
app/code/community/Auguria/Sponsorship/Block/Adminhtml/Sponsorship.php
ADDED
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* @category Auguria
|
4 |
+
* @package Auguria_Sponsorship
|
5 |
+
* @author Auguria
|
6 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
7 |
+
*/
|
8 |
+
class Auguria_Sponsorship_Block_Adminhtml_Sponsorship extends Mage_Adminhtml_Block_Widget_Grid_Container
|
9 |
+
{
|
10 |
+
public function __construct()
|
11 |
+
{
|
12 |
+
Mage_Adminhtml_Block_Widget_Container::__construct();
|
13 |
+
$this->setTemplate('widget/grid/container.phtml');
|
14 |
+
|
15 |
+
$this->_controller = 'adminhtml_sponsorship';
|
16 |
+
$this->_blockGroup = 'sponsorship';
|
17 |
+
$this->_headerText = $this->__('Invitations list');
|
18 |
+
//$this->_addButtonLabel = $this->__('Ajouter une invitation');
|
19 |
+
|
20 |
+
}
|
21 |
+
}
|
app/code/community/Auguria/Sponsorship/Block/Adminhtml/Sponsorship/Edit.php
ADDED
@@ -0,0 +1,72 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* @category Auguria
|
4 |
+
* @package Auguria_Sponsorship
|
5 |
+
* @author Auguria
|
6 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
7 |
+
*/
|
8 |
+
class Auguria_Sponsorship_Block_Adminhtml_Sponsorship_Edit extends Mage_Adminhtml_Block_Widget_Form_Container
|
9 |
+
{
|
10 |
+
public function __construct()
|
11 |
+
{
|
12 |
+
Mage_Adminhtml_Block_Widget_Container::__construct();
|
13 |
+
|
14 |
+
if (!$this->hasData('template')) {
|
15 |
+
$this->setTemplate('widget/form/container.phtml');
|
16 |
+
}
|
17 |
+
|
18 |
+
$this->_addButton('back', array(
|
19 |
+
'label' => Mage::helper('adminhtml')->__('Back'),
|
20 |
+
'onclick' => 'setLocation(\'' . $this->getBackUrl() . '\')',
|
21 |
+
'class' => 'back',
|
22 |
+
), -1);
|
23 |
+
$this->_addButton('reset', array(
|
24 |
+
'label' => Mage::helper('adminhtml')->__('Reset'),
|
25 |
+
'onclick' => 'setLocation(window.location.href)',
|
26 |
+
), -1);
|
27 |
+
|
28 |
+
$objId = $this->getRequest()->getParam($this->_objectId);
|
29 |
+
|
30 |
+
$this->_addButton('save', array(
|
31 |
+
'label' => Mage::helper('adminhtml')->__('Save'),
|
32 |
+
'onclick' => 'editForm.submit();',
|
33 |
+
'class' => 'save',
|
34 |
+
), 1);
|
35 |
+
|
36 |
+
$this->_objectId = 'id';
|
37 |
+
$this->_blockGroup = 'sponsorship';
|
38 |
+
$this->_controller = 'adminhtml_sponsorship';
|
39 |
+
|
40 |
+
$this->_updateButton('save', 'label', Mage::helper('adminhtml')->__('Save'));
|
41 |
+
$this->_updateButton('delete', 'label', Mage::helper('adminhtml')->__('Delete'));
|
42 |
+
|
43 |
+
$this->_addButton('saveandcontinue', array(
|
44 |
+
'label' => Mage::helper('adminhtml')->__('Save And Continue Edit'),
|
45 |
+
'onclick' => 'saveAndContinueEdit()',
|
46 |
+
'class' => 'save',
|
47 |
+
), -100);
|
48 |
+
|
49 |
+
$this->_formScripts[] = "
|
50 |
+
function toggleEditor() {
|
51 |
+
if (tinyMCE.getInstanceById('sponsorship_content') == null) {
|
52 |
+
tinyMCE.execCommand('mceAddControl', false, 'sponsorship_content');
|
53 |
+
} else {
|
54 |
+
tinyMCE.execCommand('mceRemoveControl', false, 'sponsorship_content');
|
55 |
+
}
|
56 |
+
}
|
57 |
+
|
58 |
+
function saveAndContinueEdit(){
|
59 |
+
editForm.submit($('edit_form').action+'back/edit/');
|
60 |
+
}
|
61 |
+
";
|
62 |
+
}
|
63 |
+
|
64 |
+
public function getHeaderText()
|
65 |
+
{
|
66 |
+
if( Mage::registry('sponsorship_data') && Mage::registry('sponsorship_data')->getId() ) {
|
67 |
+
return Mage::helper('sponsorship')->__("Edition of the invitation '%s'", $this->htmlEscape(Mage::registry('sponsorship_data')->getId()));
|
68 |
+
} else {
|
69 |
+
return Mage::helper('sponsorship')->__('Add an invitation');
|
70 |
+
}
|
71 |
+
}
|
72 |
+
}
|
app/code/community/Auguria/Sponsorship/Block/Adminhtml/Sponsorship/Edit/Form.php
ADDED
@@ -0,0 +1,24 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* @category Auguria
|
4 |
+
* @package Auguria_Sponsorship
|
5 |
+
* @author Auguria
|
6 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
7 |
+
*/
|
8 |
+
class Auguria_Sponsorship_Block_Adminhtml_Sponsorship_Edit_Form extends Mage_Adminhtml_Block_Widget_Form
|
9 |
+
{
|
10 |
+
protected function _prepareForm()
|
11 |
+
{
|
12 |
+
$form = new Varien_Data_Form(array(
|
13 |
+
'id' => 'edit_form',
|
14 |
+
'action' => $this->getUrl('*/*/save', array('id' => $this->getRequest()->getParam('id'))),
|
15 |
+
'method' => 'post',
|
16 |
+
'enctype' => 'multipart/form-data'
|
17 |
+
)
|
18 |
+
);
|
19 |
+
|
20 |
+
$form->setUseContainer(true);
|
21 |
+
$this->setForm($form);
|
22 |
+
return parent::_prepareForm();
|
23 |
+
}
|
24 |
+
}
|
app/code/community/Auguria/Sponsorship/Block/Adminhtml/Sponsorship/Edit/Tab/Form.php
ADDED
@@ -0,0 +1,48 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* @category Auguria
|
4 |
+
* @package Auguria_Sponsorship
|
5 |
+
* @author Auguria
|
6 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
7 |
+
*/
|
8 |
+
class Auguria_Sponsorship_Block_Adminhtml_Sponsorship_Edit_Tab_Form extends Mage_Adminhtml_Block_Widget_Form
|
9 |
+
{
|
10 |
+
protected function _prepareForm()
|
11 |
+
{
|
12 |
+
$form = new Varien_Data_Form();
|
13 |
+
$this->setForm($form);
|
14 |
+
$fieldset = $form->addFieldset('sponsorship_form', array('legend'=>Mage::helper('sponsorship')->__("Invitation information")));
|
15 |
+
|
16 |
+
$fieldset->addField('parent_id', 'text', array(
|
17 |
+
'label' => Mage::helper('sponsorship')->__('Related ID'),
|
18 |
+
'class' => 'required-entry',
|
19 |
+
'required' => true,
|
20 |
+
'name' => 'parent_id',
|
21 |
+
));
|
22 |
+
|
23 |
+
$fieldset->addField('child_mail', 'text', array(
|
24 |
+
'label' => Mage::helper('sponsorship')->__('Guest mail'),
|
25 |
+
'required' => true,
|
26 |
+
'name' => 'child_mail',
|
27 |
+
));
|
28 |
+
|
29 |
+
$fieldset->addField('datetime', 'date', array(
|
30 |
+
'name' => 'datetime',
|
31 |
+
'title' => Mage::helper('sponsorship')->__("Date"),
|
32 |
+
'label' => Mage::helper('sponsorship')->__("Date"),
|
33 |
+
'required' => true,
|
34 |
+
'image' => Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_SKIN).'/adminhtml/default/default/images/grid-cal.gif',
|
35 |
+
'input_format' => Mage::app()->getLocale()->getDateTimeFormat(Mage_Core_Model_Locale::FORMAT_TYPE_SHORT),
|
36 |
+
'format' => Mage::app()->getLocale()->getDateTimeFormat(Mage_Core_Model_Locale::FORMAT_TYPE_SHORT),
|
37 |
+
))->setReadonly(true, true);
|
38 |
+
|
39 |
+
if ( Mage::getSingleton('adminhtml/session')->getSponsorshipData() )
|
40 |
+
{
|
41 |
+
$form->setValues(Mage::getSingleton('adminhtml/session')->getSponsorshipData());
|
42 |
+
Mage::getSingleton('adminhtml/session')->setSponsorshipData(null);
|
43 |
+
} elseif ( Mage::registry('sponsorship_data') ) {
|
44 |
+
$form->setValues(Mage::registry('sponsorship_data')->getData());
|
45 |
+
}
|
46 |
+
return parent::_prepareForm();
|
47 |
+
}
|
48 |
+
}
|
app/code/community/Auguria/Sponsorship/Block/Adminhtml/Sponsorship/Edit/Tabs.php
ADDED
@@ -0,0 +1,29 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* @category Auguria
|
4 |
+
* @package Auguria_Sponsorship
|
5 |
+
* @author Auguria
|
6 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
7 |
+
*/
|
8 |
+
class Auguria_Sponsorship_Block_Adminhtml_Sponsorship_Edit_Tabs extends Mage_Adminhtml_Block_Widget_Tabs
|
9 |
+
{
|
10 |
+
|
11 |
+
public function __construct()
|
12 |
+
{
|
13 |
+
parent::__construct();
|
14 |
+
$this->setId('sponsorship_tabs');
|
15 |
+
$this->setDestElementId('edit_form');
|
16 |
+
$this->setTitle(Mage::helper('sponsorship')->__('Invitation detail'));
|
17 |
+
}
|
18 |
+
|
19 |
+
protected function _beforeToHtml()
|
20 |
+
{
|
21 |
+
$this->addTab('form_section', array(
|
22 |
+
'label' => Mage::helper('sponsorship')->__('Invitation detail'),
|
23 |
+
'title' => Mage::helper('sponsorship')->__('Invitation detail'),
|
24 |
+
'content' => $this->getLayout()->createBlock('sponsorship/adminhtml_sponsorship_edit_tab_form')->toHtml(),
|
25 |
+
));
|
26 |
+
|
27 |
+
return parent::_beforeToHtml();
|
28 |
+
}
|
29 |
+
}
|
app/code/community/Auguria/Sponsorship/Block/Adminhtml/Sponsorship/Grid.php
ADDED
@@ -0,0 +1,122 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* @category Auguria
|
4 |
+
* @package Auguria_Sponsorship
|
5 |
+
* @author Auguria
|
6 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
7 |
+
*/
|
8 |
+
class Auguria_Sponsorship_Block_Adminhtml_Sponsorship_Grid extends Mage_Adminhtml_Block_Widget_Grid
|
9 |
+
{
|
10 |
+
public function __construct()
|
11 |
+
{
|
12 |
+
parent::__construct();
|
13 |
+
$this->setId('sponsorshipGrid');
|
14 |
+
//$this->setUseAjax(true);
|
15 |
+
$this->setDefaultSort('sponsorship_id');
|
16 |
+
$this->setDefaultDir('ASC');
|
17 |
+
$this->setSaveParametersInSession(true);
|
18 |
+
}
|
19 |
+
|
20 |
+
protected function _prepareCollection()
|
21 |
+
{
|
22 |
+
$collection = Mage::getResourceModel('sponsorship/sponsorship_collection')
|
23 |
+
;//->addChildNameToSelect();
|
24 |
+
$this->setCollection($collection);
|
25 |
+
return parent::_prepareCollection();
|
26 |
+
}
|
27 |
+
|
28 |
+
protected function _prepareColumns()
|
29 |
+
{
|
30 |
+
$this->addColumn('sponsorship_id', array(
|
31 |
+
'header' => Mage::helper('sponsorship')->__('ID'),
|
32 |
+
'align' =>'right',
|
33 |
+
//'width' => '40px',
|
34 |
+
'index' => 'sponsorship_id',
|
35 |
+
));
|
36 |
+
|
37 |
+
$this->addColumn('parent_id', array(
|
38 |
+
'header' => Mage::helper('sponsorship')->__('Related ID'),
|
39 |
+
'align' =>'right',
|
40 |
+
//'width' => '40px',
|
41 |
+
'index' => 'parent_id',
|
42 |
+
));
|
43 |
+
|
44 |
+
$this->addColumn('parent_name', array(
|
45 |
+
'header' => Mage::helper('sponsorship')->__('Related name'),
|
46 |
+
'index' => 'parent_name',
|
47 |
+
));
|
48 |
+
|
49 |
+
$this->addColumn('parent_mail', array(
|
50 |
+
'header' => Mage::helper('sponsorship')->__('Related mail'),
|
51 |
+
'align' =>'left',
|
52 |
+
'index' => 'parent_mail',
|
53 |
+
));
|
54 |
+
|
55 |
+
$this->addColumn('child_firstname', array(
|
56 |
+
'header' => Mage::helper('sponsorship')->__('Guest first name'),
|
57 |
+
'index' => 'child_firstname',
|
58 |
+
));
|
59 |
+
$this->addColumn('child_lastname', array(
|
60 |
+
'header' => Mage::helper('sponsorship')->__('Guest last name'),
|
61 |
+
'index' => 'child_lastname',
|
62 |
+
));
|
63 |
+
|
64 |
+
$this->addColumn('child_mail', array(
|
65 |
+
'header' => Mage::helper('sponsorship')->__('Guest mail'),
|
66 |
+
'index' => 'child_mail',
|
67 |
+
));
|
68 |
+
|
69 |
+
$this->addColumn('message', array(
|
70 |
+
'header' => Mage::helper('sponsorship')->__('Message'),
|
71 |
+
'index' => 'message',
|
72 |
+
));
|
73 |
+
|
74 |
+
$this->addColumn('datetime', array(
|
75 |
+
'header' => Mage::helper('sponsorship')->__("Date"),
|
76 |
+
'align' =>'right',
|
77 |
+
'index' => 'datetime',
|
78 |
+
'type' => 'datetime',
|
79 |
+
'format' => Mage::app()->getLocale()->getDateTimeFormat(Mage_Core_Model_Locale::FORMAT_TYPE_SHORT),
|
80 |
+
));
|
81 |
+
|
82 |
+
$this->addColumn('datetime_boost', array(
|
83 |
+
'header' => Mage::helper('sponsorship')->__("Recovery date"),
|
84 |
+
'align' =>'right',
|
85 |
+
'index' => 'datetime_boost',
|
86 |
+
'type' => 'datetime',
|
87 |
+
'format' => Mage::app()->getLocale()->getDateTimeFormat(Mage_Core_Model_Locale::FORMAT_TYPE_SHORT),
|
88 |
+
));
|
89 |
+
|
90 |
+
$this->addColumn('action',
|
91 |
+
array(
|
92 |
+
'header' => Mage::helper('sponsorship')->__('Action'),
|
93 |
+
//'width' => '100',
|
94 |
+
'type' => 'action',
|
95 |
+
'getter' => 'getId',
|
96 |
+
'actions' => array(
|
97 |
+
array(
|
98 |
+
'caption' => Mage::helper('sponsorship')->__('Edit'),
|
99 |
+
'url' => array('base'=> '*/*/edit'),
|
100 |
+
'field' => 'id'
|
101 |
+
)
|
102 |
+
),
|
103 |
+
'filter' => false,
|
104 |
+
'sortable' => false,
|
105 |
+
'index' => 'stores',
|
106 |
+
'is_system' => true,
|
107 |
+
));
|
108 |
+
|
109 |
+
$this->addExportType('*/*/exportCsv', Mage::helper('sponsorship')->__('CSV'));
|
110 |
+
$this->addExportType('*/*/exportXml', Mage::helper('sponsorship')->__('XML'));
|
111 |
+
|
112 |
+
return parent::_prepareColumns();
|
113 |
+
}
|
114 |
+
|
115 |
+
|
116 |
+
|
117 |
+
public function getRowUrl($row)
|
118 |
+
{
|
119 |
+
return $this->getUrl('*/*/edit', array('id' => $row->getId()));
|
120 |
+
}
|
121 |
+
|
122 |
+
}
|
app/code/community/Auguria/Sponsorship/Block/Customer/Account/PointsDetail.php
ADDED
@@ -0,0 +1,286 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* @category Auguria
|
4 |
+
* @package Auguria_Sponsorship
|
5 |
+
* @author Auguria
|
6 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
7 |
+
*/
|
8 |
+
class Auguria_Sponsorship_Block_Customer_Account_PointsDetail extends Mage_Customer_Block_Account_Dashboard
|
9 |
+
{
|
10 |
+
public function _prepareLayout()
|
11 |
+
{
|
12 |
+
return parent::_prepareLayout();
|
13 |
+
}
|
14 |
+
|
15 |
+
public function isFidelityChangeEnabled ()
|
16 |
+
{
|
17 |
+
$isEnable = false;
|
18 |
+
if ($this->getFidelityCashConfig()) {
|
19 |
+
$isEnable = true;
|
20 |
+
}
|
21 |
+
elseif ($this->getFidelityCouponConfig()) {
|
22 |
+
$isEnable = true;
|
23 |
+
}
|
24 |
+
elseif ($this->getFidelityGiftConfig()) {
|
25 |
+
$isEnable = true;
|
26 |
+
}
|
27 |
+
return $isEnable;
|
28 |
+
}
|
29 |
+
|
30 |
+
public function isSponsorChangeEnabled ()
|
31 |
+
{
|
32 |
+
$isEnable = false;
|
33 |
+
if ($this->getSponsorCashConfig()) {
|
34 |
+
$isEnable = true;
|
35 |
+
}
|
36 |
+
elseif ($this->getSponsorCouponConfig()) {
|
37 |
+
$isEnable = true;
|
38 |
+
}
|
39 |
+
elseif ($this->getSponsorGiftConfig()) {
|
40 |
+
$isEnable = true;
|
41 |
+
}
|
42 |
+
return $isEnable;
|
43 |
+
}
|
44 |
+
|
45 |
+
public function getFidelityEnabledConfig ()
|
46 |
+
{
|
47 |
+
$fidelity_enabled = Mage::getStoreConfig('sponsorship/fidelity/fidelity_enabled');
|
48 |
+
return $fidelity_enabled;
|
49 |
+
}
|
50 |
+
|
51 |
+
public function getFidelityCashConfig ()
|
52 |
+
{
|
53 |
+
$fidelity_cash = Mage::getStoreConfig('sponsorship/fidelity/fidelity_cash');
|
54 |
+
return $fidelity_cash;
|
55 |
+
}
|
56 |
+
|
57 |
+
public function getFidelityCouponConfig ()
|
58 |
+
{
|
59 |
+
$fidelity_coupon = Mage::getStoreConfig('sponsorship/fidelity/fidelity_coupon');
|
60 |
+
return $fidelity_coupon;
|
61 |
+
}
|
62 |
+
|
63 |
+
public function getFidelityGiftConfig ()
|
64 |
+
{
|
65 |
+
$fidelity_gift = Mage::getStoreConfig('sponsorship/fidelity/fidelity_gift');
|
66 |
+
return $fidelity_gift;
|
67 |
+
}
|
68 |
+
|
69 |
+
public function getFidelityMaxCashConfig ()
|
70 |
+
{
|
71 |
+
$fidelity_max_cash = Mage::getStoreConfig('sponsorship/fidelity/fidelity_max_cash');
|
72 |
+
return $fidelity_max_cash;
|
73 |
+
}
|
74 |
+
|
75 |
+
public function getFidelityTimeMaxCashConfig ()
|
76 |
+
{
|
77 |
+
$fidelity_time_max_cash = Mage::getStoreConfig('sponsorship/fidelity/fidelity_time_max_cash');
|
78 |
+
return $fidelity_time_max_cash;
|
79 |
+
}
|
80 |
+
|
81 |
+
public function getSponsorEnabledConfig ()
|
82 |
+
{
|
83 |
+
$sponsor_enabled = Mage::getStoreConfig('sponsorship/sponsor/sponsor_enabled');
|
84 |
+
return $sponsor_enabled;
|
85 |
+
}
|
86 |
+
|
87 |
+
public function getSponsorCashConfig ()
|
88 |
+
{
|
89 |
+
$sponsor_cash = Mage::getStoreConfig('sponsorship/sponsor/sponsor_cash');
|
90 |
+
return $sponsor_cash;
|
91 |
+
}
|
92 |
+
|
93 |
+
public function getSponsorCouponConfig ()
|
94 |
+
{
|
95 |
+
$sponsor_coupon = Mage::getStoreConfig('sponsorship/sponsor/sponsor_coupon');
|
96 |
+
return $sponsor_coupon;
|
97 |
+
}
|
98 |
+
|
99 |
+
public function getSponsorGiftConfig ()
|
100 |
+
{
|
101 |
+
$sponsor_gift = Mage::getStoreConfig('sponsorship/sponsor/sponsor_gift');
|
102 |
+
return $sponsor_gift;
|
103 |
+
}
|
104 |
+
|
105 |
+
public function getSponsorMaxCashConfig ()
|
106 |
+
{
|
107 |
+
$sponsor_max_cash = Mage::getStoreConfig('sponsorship/sponsor/sponsor_max_cash');
|
108 |
+
return $sponsor_max_cash;
|
109 |
+
}
|
110 |
+
|
111 |
+
public function getSponsorTimeMaxCashConfig ()
|
112 |
+
{
|
113 |
+
$sponsor_time_max_cash = Mage::getStoreConfig('sponsorship/sponsor/sponsor_time_max_cash');
|
114 |
+
return $sponsor_time_max_cash;
|
115 |
+
}
|
116 |
+
|
117 |
+
public function getSponsorPointsToCashConfig ()
|
118 |
+
{
|
119 |
+
$sponsor_points_to_cash = Mage::getStoreConfig('sponsorship/sponsor/sponsor_points_to_cash');
|
120 |
+
return $sponsor_points_to_cash;
|
121 |
+
}
|
122 |
+
|
123 |
+
public function getFidelityPointsToCashConfig ()
|
124 |
+
{
|
125 |
+
$fidelity_points_to_cash = Mage::getStoreConfig('sponsorship/fidelity/fidelity_points_to_cash');
|
126 |
+
return $fidelity_points_to_cash;
|
127 |
+
}
|
128 |
+
|
129 |
+
public function getUserId()
|
130 |
+
{
|
131 |
+
if (!Mage::getSingleton('customer/session')->isLoggedIn()) {
|
132 |
+
return '';
|
133 |
+
}
|
134 |
+
$customer = Mage::getSingleton('customer/session')->getCustomerId();
|
135 |
+
return ($customer);
|
136 |
+
}
|
137 |
+
|
138 |
+
public function getParrainages() {
|
139 |
+
$parrains = Mage::getModel("customer/customer")
|
140 |
+
->getCollection()
|
141 |
+
->addNameToSelect()
|
142 |
+
->addAttributeToFilter('sponsor', $this->getUserId());
|
143 |
+
$parrains = $parrains->getData();
|
144 |
+
return $parrains;
|
145 |
+
}
|
146 |
+
|
147 |
+
public function getNbParrainages ($customerId)
|
148 |
+
{
|
149 |
+
$sponsor = Mage::getModel("customer/customer")
|
150 |
+
->getCollection()
|
151 |
+
//->addExpressionAttributeToSelect('nbSponsor','COUNT("entity_id")','sponsor')
|
152 |
+
->addFilter('e.is_active', 1)
|
153 |
+
->addAttributeToFilter('sponsor', $customerId)
|
154 |
+
//->groupByAttribute('entity_id');
|
155 |
+
->count();
|
156 |
+
return $sponsor;
|
157 |
+
}
|
158 |
+
|
159 |
+
public function getDateDernCde ($customerId)
|
160 |
+
{
|
161 |
+
$commande = Mage::getModel("sales/order")
|
162 |
+
->getCollection()
|
163 |
+
->addAttributeToFilter('customer_id',$customerId)
|
164 |
+
->addAttributeToSort('created_at', 'desc')
|
165 |
+
->getLastItem();
|
166 |
+
if ($commande) {
|
167 |
+
return $commande['created_at'];
|
168 |
+
}
|
169 |
+
else {
|
170 |
+
return null;
|
171 |
+
}
|
172 |
+
|
173 |
+
}
|
174 |
+
|
175 |
+
public function getCommandes()
|
176 |
+
{
|
177 |
+
$commandes = Mage::getModel("sales/order")
|
178 |
+
->getCollection()
|
179 |
+
->addAttributeToFilter('customer_id',$this->getUserId())
|
180 |
+
->addAttributeToSort('created_at', 'desc')
|
181 |
+
->setPageSize(5);
|
182 |
+
return $commandes->getData();
|
183 |
+
}
|
184 |
+
|
185 |
+
public function getOrderFidelityPoints($orderId)
|
186 |
+
{
|
187 |
+
$order = Mage::getModel("sales/order")->load($orderId);
|
188 |
+
$points = 0;
|
189 |
+
|
190 |
+
foreach ($order->getAllItems() as $item)
|
191 |
+
{
|
192 |
+
$points = $points + $item->getCartFidelityPoints() + $item->getCatalogFidelityPoints();
|
193 |
+
}
|
194 |
+
return $points;
|
195 |
+
}
|
196 |
+
|
197 |
+
public function getOrderSponsorPoints($orderId)
|
198 |
+
{
|
199 |
+
$order = Mage::getModel("sales/order")->load($orderId);
|
200 |
+
$points = 0;
|
201 |
+
|
202 |
+
foreach ($order->getAllItems() as $item)
|
203 |
+
{
|
204 |
+
$points = $points + $item->getCartSponsorPoints() + $item->getCatalogSponsorPoints();
|
205 |
+
}
|
206 |
+
return $points;
|
207 |
+
}
|
208 |
+
|
209 |
+
public function getFidelityPoints()
|
210 |
+
{
|
211 |
+
$customer = Mage::getModel("customer/customer")->load($this->getUserId());
|
212 |
+
$cFP = $customer->getData('fidelity_points');
|
213 |
+
return $cFP;
|
214 |
+
}
|
215 |
+
|
216 |
+
public function getSponsorPoints()
|
217 |
+
{
|
218 |
+
$customer = Mage::getModel("customer/customer")->load($this->getUserId());
|
219 |
+
$cSP = $customer->getData('sponsor_points');
|
220 |
+
return $cSP;
|
221 |
+
}
|
222 |
+
|
223 |
+
public function getBranchPoints($customerId)
|
224 |
+
{
|
225 |
+
try {
|
226 |
+
$resource = Mage::getSingleton('core/resource');
|
227 |
+
$read = $resource->getConnection('core_read');
|
228 |
+
|
229 |
+
$select = $read->select()
|
230 |
+
->from($resource->getTableName('sponsorship/sponsorlog'), 'SUM(points)')
|
231 |
+
->where('godson_id=?', $customerId)
|
232 |
+
->where('sponsor_id=?', $this->getUserId());
|
233 |
+
return $read->fetchOne($select);
|
234 |
+
}
|
235 |
+
catch (Exception $e) {
|
236 |
+
}
|
237 |
+
}
|
238 |
+
|
239 |
+
public function hasChange($module)
|
240 |
+
{
|
241 |
+
$changes = mage::getModel("sponsorship/change")
|
242 |
+
->getCollection()
|
243 |
+
->addAttributeToFilter("module", $module)
|
244 |
+
->addAttributeToFilter("customer_id", $this->getUserId())
|
245 |
+
->count();
|
246 |
+
if ($changes)
|
247 |
+
{
|
248 |
+
return true;
|
249 |
+
}
|
250 |
+
else
|
251 |
+
{
|
252 |
+
return false;
|
253 |
+
}
|
254 |
+
}
|
255 |
+
|
256 |
+
public function getChanges($module)
|
257 |
+
{
|
258 |
+
$changes = mage::getModel("sponsorship/change")
|
259 |
+
->getCollection()
|
260 |
+
->addAttributeToFilter("module", $module)
|
261 |
+
->addAttributeToFilter("customer_id", $this->getUserId())
|
262 |
+
->setOrder('datetime', 'desc')
|
263 |
+
->setPageSize(5);
|
264 |
+
return $changes;
|
265 |
+
}
|
266 |
+
|
267 |
+
public function getInvits()
|
268 |
+
{
|
269 |
+
/*
|
270 |
+
* select s.* from sponsorship s
|
271 |
+
where s.parent_id =1
|
272 |
+
and s.child_mail not in (select ce.email from customer_entity ce )
|
273 |
+
and s.datetime = (select max(sp.datetime) from sponsorship sp where sp.parent_id=1 and sp.child_mail = s.child_mail)
|
274 |
+
*/
|
275 |
+
$resource = Mage::getSingleton('core/resource');
|
276 |
+
$read = $resource->getConnection('core_read');
|
277 |
+
$select = $read->select()
|
278 |
+
->from(Array("s"=>$resource->getTableName('sponsorship/sponsorship')),
|
279 |
+
Array("*"=>"s.*"))
|
280 |
+
->where('s.parent_id=?', $this->getUserId())
|
281 |
+
->where('TO_DAYS(NOW()) - TO_DAYS(s.datetime) <= ?', Mage::getStoreConfig('sponsorship/invit_email/sponsor_invitation_validity'))
|
282 |
+
->where('s.child_mail NOT IN ?', new Zend_Db_Expr('(select ce.email from '.$resource->getTableName('customer_entity').' ce)'))
|
283 |
+
->where('s.datetime = ?', new Zend_Db_Expr('(select max(sp.datetime) from '.$resource->getTableName('sponsorship/sponsorship').' sp where sp.parent_id=s.parent_id and sp.child_mail = s.child_mail)'));
|
284 |
+
return $read->fetchAll($select);
|
285 |
+
}
|
286 |
+
}
|
app/code/community/Auguria/Sponsorship/Block/Customer/Form/Boost.php
ADDED
@@ -0,0 +1,41 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* @category Auguria
|
4 |
+
* @package Auguria_Sponsorship
|
5 |
+
* @author Auguria
|
6 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
7 |
+
*/
|
8 |
+
class Auguria_Sponsorship_Block_Customer_Form_Boost extends Mage_Customer_Block_Account_Dashboard
|
9 |
+
{
|
10 |
+
public function _prepareLayout()
|
11 |
+
{
|
12 |
+
return parent::_prepareLayout();
|
13 |
+
}
|
14 |
+
|
15 |
+
public function getInvit()
|
16 |
+
{
|
17 |
+
$param = $this->getRequest()->get("sponsorship_id");
|
18 |
+
if ( $param )
|
19 |
+
{
|
20 |
+
$invit = mage::getModel("sponsorship/sponsorship")->load($param);
|
21 |
+
if ($invit->getParentId() == Mage::getSingleton('customer/session')->getId())
|
22 |
+
{
|
23 |
+
return $invit;
|
24 |
+
}
|
25 |
+
else
|
26 |
+
{
|
27 |
+
return false;
|
28 |
+
}
|
29 |
+
}
|
30 |
+
else
|
31 |
+
{
|
32 |
+
return false;
|
33 |
+
}
|
34 |
+
}
|
35 |
+
|
36 |
+
public function getParentEmail()
|
37 |
+
{
|
38 |
+
$customer = Mage::getSingleton('customer/session')->getCustomer();
|
39 |
+
return $customer->getEmail();
|
40 |
+
}
|
41 |
+
}
|
app/code/community/Auguria/Sponsorship/Block/Customer/Form/PointsChange.php
ADDED
@@ -0,0 +1,52 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* @category Auguria
|
4 |
+
* @package Auguria_Sponsorship
|
5 |
+
* @author Auguria
|
6 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
7 |
+
*/
|
8 |
+
class Auguria_Sponsorship_Block_Customer_Form_PointsChange extends Mage_Customer_Block_Account_Dashboard
|
9 |
+
{
|
10 |
+
public function _prepareLayout()
|
11 |
+
{
|
12 |
+
return parent::_prepareLayout();
|
13 |
+
}
|
14 |
+
|
15 |
+
public function getChange()
|
16 |
+
{
|
17 |
+
$module = $this->getRequest()->getParam('module');
|
18 |
+
$type = $this->getRequest()->getParam('type');
|
19 |
+
return Array ('module'=>$module, 'type'=>$type);
|
20 |
+
}
|
21 |
+
|
22 |
+
public function getCustomerId()
|
23 |
+
{
|
24 |
+
if (!Mage::getSingleton('customer/session')->isLoggedIn()) {
|
25 |
+
return '';
|
26 |
+
}
|
27 |
+
$customerId = Mage::getSingleton('customer/session')->getCustomerId();
|
28 |
+
return ($customerId);
|
29 |
+
}
|
30 |
+
|
31 |
+
public function getFidelityPoints()
|
32 |
+
{
|
33 |
+
$customer = Mage::getModel("customer/customer")->load($this->getCustomerId());
|
34 |
+
$cFP = $customer->getData('fidelity_points');
|
35 |
+
return $cFP;
|
36 |
+
}
|
37 |
+
|
38 |
+
public function getSponsorPoints()
|
39 |
+
{
|
40 |
+
$customer = Mage::getModel("customer/customer")->load($this->getCustomerId());
|
41 |
+
$cSP = $customer->getData('sponsor_points');
|
42 |
+
return $cSP;
|
43 |
+
}
|
44 |
+
|
45 |
+
public function getPointsToCashConfig ($Module)
|
46 |
+
{
|
47 |
+
$options = Mage::getBlockSingleton('sponsorship/customer_account_pointsDetail');
|
48 |
+
$PointsToCashFunction = 'get'.$Module.'PointsToCashConfig';
|
49 |
+
$PointsToCash = $options->$PointsToCashFunction();
|
50 |
+
return $PointsToCash;
|
51 |
+
}
|
52 |
+
}
|
app/code/community/Auguria/Sponsorship/Block/Customer/Widget/Name.php
ADDED
@@ -0,0 +1,33 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* @category Auguria
|
4 |
+
* @package Auguria_Sponsorship
|
5 |
+
* @author Auguria
|
6 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
7 |
+
*/
|
8 |
+
class Auguria_Sponsorship_Block_Customer_Widget_Name extends Mage_Customer_Block_Widget_Name
|
9 |
+
{
|
10 |
+
public function _construct()
|
11 |
+
{
|
12 |
+
Mage_Customer_Block_Widget_Abstract::_construct();
|
13 |
+
|
14 |
+
// default template location
|
15 |
+
$this->setTemplate('sponsorship/customer/widget/name.phtml');
|
16 |
+
}
|
17 |
+
|
18 |
+
public function getInvit ($param)
|
19 |
+
{
|
20 |
+
$value = '';
|
21 |
+
$cookie = new Mage_Core_Model_Cookie;
|
22 |
+
if (Mage::getSingleton('core/session')->getData($param))
|
23 |
+
{
|
24 |
+
$value = Mage::getSingleton('core/session')->getData($param);
|
25 |
+
|
26 |
+
}
|
27 |
+
elseif ($cookie->get('sponsorship_'.$param))
|
28 |
+
{
|
29 |
+
$value = $cookie->get('sponsorship_'.$param);
|
30 |
+
}
|
31 |
+
return $value;
|
32 |
+
}
|
33 |
+
}
|
app/code/community/Auguria/Sponsorship/Block/Customer/Widget/Virement.php
ADDED
@@ -0,0 +1,42 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* @category Auguria
|
4 |
+
* @package Auguria_Sponsorship
|
5 |
+
* @author Auguria
|
6 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
7 |
+
*/
|
8 |
+
class Auguria_Sponsorship_Block_Customer_Widget_Virement extends Mage_Customer_Block_Widget_Abstract
|
9 |
+
{
|
10 |
+
public function _construct()
|
11 |
+
{
|
12 |
+
parent::_construct();
|
13 |
+
$this->setTemplate('sponsorship/customer/widget/virement.phtml');
|
14 |
+
}
|
15 |
+
|
16 |
+
public function isEnabled()
|
17 |
+
{
|
18 |
+
//Ajouter si module parrainage actif
|
19 |
+
|
20 |
+
//iban et siret actifs si le client est parrain
|
21 |
+
$customer = Mage::getModel('customer/customer')
|
22 |
+
->getCollection()
|
23 |
+
->addAttributeToFilter('sponsor', $this->getCustomer()->getId());
|
24 |
+
if ($customer->getData() || $this->getCustomer()->getFidelityPoints() != null) {
|
25 |
+
return true;
|
26 |
+
}
|
27 |
+
else {
|
28 |
+
return false;
|
29 |
+
}
|
30 |
+
}
|
31 |
+
|
32 |
+
/*
|
33 |
+
public function isRequired()
|
34 |
+
{
|
35 |
+
return 'req' == $this->getConfig('taxvat_show');
|
36 |
+
}
|
37 |
+
*/
|
38 |
+
public function getCustomer()
|
39 |
+
{
|
40 |
+
return Mage::getSingleton('customer/session')->getCustomer();
|
41 |
+
}
|
42 |
+
}
|
app/code/community/Auguria/Sponsorship/Block/Promo/Catalog/Edit/Tab/Actions.php
ADDED
@@ -0,0 +1,69 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* @category Auguria
|
4 |
+
* @package Auguria_Sponsorship
|
5 |
+
* @author Auguria
|
6 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
7 |
+
*/
|
8 |
+
class Auguria_Sponsorship_Block_Promo_Catalog_Edit_Tab_Actions extends Mage_Adminhtml_Block_Promo_Catalog_Edit_Tab_Actions
|
9 |
+
{
|
10 |
+
protected function _prepareForm()
|
11 |
+
{
|
12 |
+
$model = Mage::registry('current_promo_catalog_rule');
|
13 |
+
|
14 |
+
//$form = new Varien_Data_Form(array('id' => 'edit_form1', 'action' => $this->getData('action'), 'method' => 'post'));
|
15 |
+
$form = new Varien_Data_Form();
|
16 |
+
|
17 |
+
$form->setHtmlIdPrefix('rule_');
|
18 |
+
|
19 |
+
$fieldset = $form->addFieldset('action_fieldset', array('legend'=>Mage::helper('salesrule')->__('Update prices using the following information')));
|
20 |
+
|
21 |
+
$fieldset->addField('simple_action', 'select', array(
|
22 |
+
'label' => Mage::helper('salesrule')->__('Apply'),
|
23 |
+
'name' => 'simple_action',
|
24 |
+
'options' => array(
|
25 |
+
'by_percent' => Mage::helper('salesrule')->__('By Percentage of the original price'),
|
26 |
+
'by_fixed' => Mage::helper('salesrule')->__('By Fixed Amount'),
|
27 |
+
'to_percent' => Mage::helper('salesrule')->__('To Percentage of the original price'),
|
28 |
+
'to_fixed' => Mage::helper('salesrule')->__('To Fixed Amount'),
|
29 |
+
'fidelity_points_to_percent' => $this->__('Fidelity points by percentage of the original price'),
|
30 |
+
'fidelity_points_to_fixed' => $this->__('Fidelity points by fixed amount'),
|
31 |
+
'sponsor_points_to_percent' => $this->__('Sponsorship points by percentage of the original price'),
|
32 |
+
'sponsor_points_to_fixed' => $this->__('Sponsorship points by fixed amount'),
|
33 |
+
),
|
34 |
+
));
|
35 |
+
|
36 |
+
$fieldset->addField('discount_amount', 'text', array(
|
37 |
+
'name' => 'discount_amount',
|
38 |
+
'required' => true,
|
39 |
+
'class' => 'validate-not-negative-number',
|
40 |
+
'label' => Mage::helper('salesrule')->__('Discount amount'),
|
41 |
+
));
|
42 |
+
|
43 |
+
$fieldset->addField('stop_rules_processing', 'select', array(
|
44 |
+
'label' => Mage::helper('salesrule')->__('Stop further rules processing'),
|
45 |
+
'title' => Mage::helper('salesrule')->__('Stop further rules processing'),
|
46 |
+
'name' => 'stop_rules_processing',
|
47 |
+
'options' => array(
|
48 |
+
'1' => Mage::helper('salesrule')->__('Yes'),
|
49 |
+
'0' => Mage::helper('salesrule')->__('No'),
|
50 |
+
),
|
51 |
+
));
|
52 |
+
|
53 |
+
$form->setValues($model->getData());
|
54 |
+
|
55 |
+
//$form->setUseContainer(true);
|
56 |
+
|
57 |
+
if ($model->isReadonly()) {
|
58 |
+
foreach ($fieldset->getElements() as $element) {
|
59 |
+
$element->setReadonly(true, true);
|
60 |
+
}
|
61 |
+
}
|
62 |
+
|
63 |
+
$this->setForm($form);
|
64 |
+
|
65 |
+
//return parent::_prepareForm();
|
66 |
+
return Mage_Adminhtml_Block_Widget_Form::_prepareForm();
|
67 |
+
|
68 |
+
}
|
69 |
+
}
|
app/code/community/Auguria/Sponsorship/Block/Promo/Quote/Edit/Tab/Actions.php
ADDED
@@ -0,0 +1,107 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* @category Auguria
|
4 |
+
* @package Auguria_Sponsorship
|
5 |
+
* @author Auguria
|
6 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
7 |
+
*/
|
8 |
+
class Auguria_Sponsorship_Block_Promo_Quote_Edit_Tab_Actions extends Mage_Adminhtml_Block_Promo_Quote_Edit_Tab_Actions
|
9 |
+
{
|
10 |
+
protected function _prepareForm()
|
11 |
+
{
|
12 |
+
$model = Mage::registry('current_promo_quote_rule');
|
13 |
+
|
14 |
+
//$form = new Varien_Data_Form(array('id' => 'edit_form1', 'action' => $this->getData('action'), 'method' => 'post'));
|
15 |
+
$form = new Varien_Data_Form();
|
16 |
+
|
17 |
+
$form->setHtmlIdPrefix('rule_');
|
18 |
+
|
19 |
+
$fieldset = $form->addFieldset('action_fieldset', array('legend'=>Mage::helper('salesrule')->__('Update prices using the following information')));
|
20 |
+
|
21 |
+
$fieldset->addField('simple_action', 'select', array(
|
22 |
+
'label' => Mage::helper('salesrule')->__('Apply'),
|
23 |
+
'name' => 'simple_action',
|
24 |
+
'options' => array(
|
25 |
+
'by_percent' => Mage::helper('salesrule')->__('Percent of product price discount'),
|
26 |
+
'by_fixed' => Mage::helper('salesrule')->__('Fixed amount discount'),
|
27 |
+
'cart_fixed' => Mage::helper('salesrule')->__('Fixed amount discount for whole cart'),
|
28 |
+
'buy_x_get_y' => Mage::helper('salesrule')->__('Buy X get Y free (discount amount is Y)'),
|
29 |
+
'fidelity_points_by_percent' => $this->__('Fidelity points by percentage of the original price'),
|
30 |
+
'fidelity_points_by_fixed' => $this->__('Fidelity points by fixed amount'),
|
31 |
+
'fidelity_points_cart_fixed' => $this->__('Fidelity points by fixed amount for whole cart'),
|
32 |
+
'sponsor_points_by_percent' => $this->__('Sponsorship points by percentage of the original price'),
|
33 |
+
'sponsor_points_by_fixed' => $this->__('Sponsorship points by fixed amount'),
|
34 |
+
'sponsor_points_cart_fixed' => $this->__('Sponsorship points by fixed amount for whole cart'),
|
35 |
+
),
|
36 |
+
));
|
37 |
+
$fieldset->addField('discount_amount', 'text', array(
|
38 |
+
'name' => 'discount_amount',
|
39 |
+
'required' => true,
|
40 |
+
'class' => 'validate-not-negative-number',
|
41 |
+
'label' => Mage::helper('salesrule')->__('Discount amount'),
|
42 |
+
));
|
43 |
+
$model->setDiscountAmount($model->getDiscountAmount()*1);
|
44 |
+
|
45 |
+
$fieldset->addField('discount_qty', 'text', array(
|
46 |
+
'name' => 'discount_qty',
|
47 |
+
'label' => Mage::helper('salesrule')->__('Maximum Qty Discount is Applied to'),
|
48 |
+
));
|
49 |
+
$model->setDiscountQty($model->getDiscountQty()*1);
|
50 |
+
|
51 |
+
$fieldset->addField('discount_step', 'text', array(
|
52 |
+
'name' => 'discount_step',
|
53 |
+
'label' => Mage::helper('salesrule')->__('Discount Qty Step (Buy X)'),
|
54 |
+
));
|
55 |
+
|
56 |
+
$fieldset->addField('simple_free_shipping', 'select', array(
|
57 |
+
'label' => Mage::helper('salesrule')->__('Free shipping'),
|
58 |
+
'title' => Mage::helper('salesrule')->__('Free shipping'),
|
59 |
+
'name' => 'simple_free_shipping',
|
60 |
+
'options' => array(
|
61 |
+
0 => Mage::helper('salesrule')->__('No'),
|
62 |
+
Mage_SalesRule_Model_Rule::FREE_SHIPPING_ITEM => Mage::helper('salesrule')->__('For matching items only'),
|
63 |
+
Mage_SalesRule_Model_Rule::FREE_SHIPPING_ADDRESS => Mage::helper('salesrule')->__('For shipment with matching items'),
|
64 |
+
),
|
65 |
+
));
|
66 |
+
|
67 |
+
$fieldset->addField('stop_rules_processing', 'select', array(
|
68 |
+
'label' => Mage::helper('salesrule')->__('Stop further rules processing'),
|
69 |
+
'title' => Mage::helper('salesrule')->__('Stop further rules processing'),
|
70 |
+
'name' => 'stop_rules_processing',
|
71 |
+
'options' => array(
|
72 |
+
'1' => Mage::helper('salesrule')->__('Yes'),
|
73 |
+
'0' => Mage::helper('salesrule')->__('No'),
|
74 |
+
),
|
75 |
+
));
|
76 |
+
|
77 |
+
$renderer = Mage::getBlockSingleton('adminhtml/widget_form_renderer_fieldset')
|
78 |
+
->setTemplate('promo/fieldset.phtml')
|
79 |
+
->setNewChildUrl($this->getUrl('*/promo_quote/newActionHtml/form/rule_actions_fieldset'));
|
80 |
+
|
81 |
+
$fieldset = $form->addFieldset('actions_fieldset', array(
|
82 |
+
'legend'=>Mage::helper('salesrule')->__('Apply the rule only to cart items matching the following conditions (leave blank for all items)')
|
83 |
+
))->setRenderer($renderer);
|
84 |
+
|
85 |
+
$fieldset->addField('actions', 'text', array(
|
86 |
+
'name' => 'actions',
|
87 |
+
'label' => Mage::helper('salesrule')->__('Apply to'),
|
88 |
+
'title' => Mage::helper('salesrule')->__('Apply to'),
|
89 |
+
'required' => true,
|
90 |
+
))->setRule($model)->setRenderer(Mage::getBlockSingleton('rule/actions'));
|
91 |
+
|
92 |
+
$form->setValues($model->getData());
|
93 |
+
|
94 |
+
if ($model->isReadonly()) {
|
95 |
+
foreach ($fieldset->getElements() as $element) {
|
96 |
+
$element->setReadonly(true, true);
|
97 |
+
}
|
98 |
+
}
|
99 |
+
//$form->setUseContainer(true);
|
100 |
+
|
101 |
+
$this->setForm($form);
|
102 |
+
|
103 |
+
//return parent::_prepareForm();
|
104 |
+
return Mage_Adminhtml_Block_Widget_Form::_prepareForm();
|
105 |
+
}
|
106 |
+
|
107 |
+
}
|
app/code/community/Auguria/Sponsorship/Block/Sponsorship.php
ADDED
@@ -0,0 +1,65 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* @category Auguria
|
4 |
+
* @package Auguria_Sponsorship
|
5 |
+
* @author Auguria
|
6 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
7 |
+
*/
|
8 |
+
class Auguria_Sponsorship_Block_Sponsorship extends Mage_Core_Block_Template
|
9 |
+
{
|
10 |
+
public function _prepareLayout()
|
11 |
+
{
|
12 |
+
return parent::_prepareLayout();
|
13 |
+
}
|
14 |
+
|
15 |
+
public function getSponsorship()
|
16 |
+
{
|
17 |
+
if (!$this->hasData('sponsorship'))
|
18 |
+
{
|
19 |
+
$this->setData('sponsorship', Mage::registry('sponsorship'));
|
20 |
+
}
|
21 |
+
return $this->getData('sponsorship');
|
22 |
+
}
|
23 |
+
|
24 |
+
public function getMaxRecipients()
|
25 |
+
{
|
26 |
+
return Mage::getStoreConfig('sponsorship/invitation_email/max_recipients');
|
27 |
+
}
|
28 |
+
|
29 |
+
public function getUserName()
|
30 |
+
{
|
31 |
+
if (!Mage::getSingleton('customer/session')->isLoggedIn()) {
|
32 |
+
return '';
|
33 |
+
}
|
34 |
+
$customer = Mage::getSingleton('customer/session')->getCustomer();
|
35 |
+
return trim($customer->getFirstname()).' '.trim($customer->getLastname());
|
36 |
+
}
|
37 |
+
|
38 |
+
public function getCustomerId ()
|
39 |
+
{
|
40 |
+
if (!Mage::getSingleton('customer/session')->isLoggedIn()) {
|
41 |
+
return '';
|
42 |
+
}
|
43 |
+
return Mage::getSingleton('customer/session')->getCustomerId();
|
44 |
+
}
|
45 |
+
|
46 |
+
public function getUserEmail()
|
47 |
+
{
|
48 |
+
if (!Mage::getSingleton('customer/session')->isLoggedIn()) {
|
49 |
+
return '';
|
50 |
+
}
|
51 |
+
$customer = Mage::getSingleton('customer/session')->getCustomer();
|
52 |
+
return $customer->getEmail();
|
53 |
+
}
|
54 |
+
|
55 |
+
public function getFooterMessage()
|
56 |
+
{
|
57 |
+
return Mage::helper('sponsorship/mail')->getFooterMessage ($this->getCustomerId());
|
58 |
+
}
|
59 |
+
|
60 |
+
public function getBackUrl()
|
61 |
+
{
|
62 |
+
$back_url = isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : $this->getUrl('customer/account/');
|
63 |
+
return $back_url;
|
64 |
+
}
|
65 |
+
}
|
app/code/community/Auguria/Sponsorship/Helper/Data.php
ADDED
@@ -0,0 +1,67 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* @category Auguria
|
4 |
+
* @package Auguria_Sponsorship
|
5 |
+
* @author Auguria
|
6 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
7 |
+
*/
|
8 |
+
class Auguria_Sponsorship_Helper_Data extends Mage_Core_Helper_Abstract
|
9 |
+
{
|
10 |
+
/*
|
11 |
+
public function versionIsgreaterThanOneThree()
|
12 |
+
{
|
13 |
+
$currentVersion = Mage::getVersion();
|
14 |
+
if (version_compare($currentVersion, '1.4.0')>=0)
|
15 |
+
return true;
|
16 |
+
else
|
17 |
+
return false;
|
18 |
+
}
|
19 |
+
*/
|
20 |
+
|
21 |
+
public function haveOrder ()
|
22 |
+
{
|
23 |
+
$cId = $this->getCustomerId();
|
24 |
+
$commande = Mage::getModel("sales/order")
|
25 |
+
->getCollection()
|
26 |
+
->addAttributeToFilter('customer_id',$cId);
|
27 |
+
if ($commande->getData()) {
|
28 |
+
return true;
|
29 |
+
}
|
30 |
+
else {
|
31 |
+
return false;
|
32 |
+
}
|
33 |
+
}
|
34 |
+
|
35 |
+
//Ajout de la methode pour rechercher l'id d'un parrain eventuel
|
36 |
+
public function searchSponsorId($emailCustomer)
|
37 |
+
{
|
38 |
+
$idParrain = '';
|
39 |
+
$cookie = new Mage_Core_Model_Cookie;
|
40 |
+
$sponsorInvitationValidity = Mage::getStoreConfig('sponsorship/sponsor/sponsor_invitation_validity');
|
41 |
+
//recherche du mail dans les logs actifs
|
42 |
+
$parrainageLog = Mage::getModel("sponsorship/sponsorship")
|
43 |
+
->getCollection()
|
44 |
+
->addAttributeToFilter('child_mail', $emailCustomer)
|
45 |
+
->addDateToFilter('datetime', $sponsorInvitationValidity)
|
46 |
+
->setOrder('datetime','asc')
|
47 |
+
->getLastItem();
|
48 |
+
//si mail dans les logs parrain selection du log actif le plus ancien
|
49 |
+
$parrain = $parrainageLog->getData('parent_id');
|
50 |
+
if ($parrain != '') {
|
51 |
+
$idParrain = $parrain['parent_id'];
|
52 |
+
}
|
53 |
+
//sinon, si il existe on prend l'id stocké dans le cookie
|
54 |
+
else {
|
55 |
+
if ($cookie->get('sponsorship_id')) {
|
56 |
+
$idParrain = $cookie->get('sponsorship_id');
|
57 |
+
}
|
58 |
+
//sinon, si il existe on prend l'id stocké dans la session : au cas où les cookies sont désactivés.
|
59 |
+
else {
|
60 |
+
if (Mage::getSingleton('core/session')->getData('sponsor_id')) {
|
61 |
+
$idParrain = Mage::getSingleton('core/session')->getData('sponsor_id');
|
62 |
+
}
|
63 |
+
}
|
64 |
+
}
|
65 |
+
return $idParrain;
|
66 |
+
}
|
67 |
+
}
|
app/code/community/Auguria/Sponsorship/Helper/Mail.php
ADDED
@@ -0,0 +1,267 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* @category Auguria
|
4 |
+
* @package Auguria_Sponsorship
|
5 |
+
* @author Auguria
|
6 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
7 |
+
*/
|
8 |
+
class Auguria_Sponsorship_Helper_Mail extends Mage_Core_Helper_Abstract
|
9 |
+
{
|
10 |
+
public function getStoreName()
|
11 |
+
{
|
12 |
+
return Mage::app()->getGroup()->getName();
|
13 |
+
}
|
14 |
+
|
15 |
+
public function getSubject ()
|
16 |
+
{
|
17 |
+
return $this->__("Invitation to %s",$this->getStoreName());
|
18 |
+
}
|
19 |
+
|
20 |
+
public function getHeaderMessage ($prenom, $nom)
|
21 |
+
{
|
22 |
+
return $this->__('Dear %s %s,',$prenom, $nom);
|
23 |
+
}
|
24 |
+
|
25 |
+
public function getMessage ()
|
26 |
+
{
|
27 |
+
return $this->__('You should visit this website. It offers interesting products.');
|
28 |
+
}
|
29 |
+
|
30 |
+
public function getSponsorUrl ($id, $prenom, $nom, $email)
|
31 |
+
{
|
32 |
+
return Mage::getUrl('sponsorship/sponsor',Array ('sponsor_id'=> $id, 'nom'=>$nom , 'prenom'=>$prenom, 'email'=>$email));
|
33 |
+
|
34 |
+
}
|
35 |
+
|
36 |
+
public function getFooterMessage ($id='',$prenom='', $nom='', $email='')
|
37 |
+
{
|
38 |
+
$url = $this->getSponsorUrl($id, $prenom, $nom, $email);
|
39 |
+
return $this->__("<a href='%s'>%s</a>", $url, $this->getUrlWtHttp());
|
40 |
+
}
|
41 |
+
|
42 |
+
public function getUrlWtHttp()
|
43 |
+
{
|
44 |
+
$url = eregi_replace("(http://)|(/index.php)|[/]$", "", Mage::getUrl());
|
45 |
+
return $url;
|
46 |
+
}
|
47 |
+
|
48 |
+
public function htmlToText ($html)
|
49 |
+
{
|
50 |
+
$h2t = new Auguria_Sponsorship_Lib_Html2Text($html);
|
51 |
+
return $h2t->get_text();
|
52 |
+
}
|
53 |
+
|
54 |
+
public function recipientMailIsCustomer($mail)
|
55 |
+
{
|
56 |
+
$customer = mage::getModel("customer/customer")
|
57 |
+
->getCollection()
|
58 |
+
->addAttributeToFilter("email",$mail);
|
59 |
+
if (count($customer)==1)
|
60 |
+
{
|
61 |
+
return true;
|
62 |
+
}
|
63 |
+
else
|
64 |
+
{
|
65 |
+
return false;
|
66 |
+
}
|
67 |
+
}
|
68 |
+
|
69 |
+
public function processMail($post)
|
70 |
+
{
|
71 |
+
//recupération des données fixes pour tous les mails
|
72 |
+
//sender
|
73 |
+
$sender_name = ucwords(strtolower($post["sender"]["name"]));
|
74 |
+
$sender_email = $post['sender']['email'];
|
75 |
+
$sender_id = $post['sender']['id'];
|
76 |
+
|
77 |
+
//message
|
78 |
+
$subject = $post['message']['subject'];
|
79 |
+
$body = $post['message']['body'];
|
80 |
+
|
81 |
+
$date = now();
|
82 |
+
|
83 |
+
//Boucle pour traiter les champs, les valider et les intégrer dans tableau mail
|
84 |
+
$i = 0;
|
85 |
+
$mails = Array();
|
86 |
+
$valid = true;
|
87 |
+
foreach ($post['recipient']['email'] as $recipient_email)
|
88 |
+
{
|
89 |
+
$mails[$i]["sender_name"] = $sender_name;
|
90 |
+
$mails[$i]["sender_email"] = $sender_email;
|
91 |
+
$mails[$i]["sender_id"] = $sender_id;
|
92 |
+
|
93 |
+
$recipient_firstname = ucwords(strtolower($post['recipient']['firstname'][$i]));
|
94 |
+
$recipient_lastname = ucwords(strtolower($post['recipient']['lastname'][$i]));
|
95 |
+
$mails[$i]["recipient_firstname"] = $recipient_firstname;
|
96 |
+
$mails[$i]["recipient_lastname"] = $recipient_lastname;
|
97 |
+
$mails[$i]["recipient_email"] = $recipient_email;
|
98 |
+
|
99 |
+
//si header indiqué : construction du header et intégration au message
|
100 |
+
$mails[$i]["subject"] = $subject;
|
101 |
+
$htmlMessage = "";
|
102 |
+
//si un id est envoyé : c'est une modification
|
103 |
+
if (isset ($post['sponsorship_id']))
|
104 |
+
{
|
105 |
+
$mails[$i]["sponsorship_id"] = $post['sponsorship_id'];
|
106 |
+
$htmlMessage = $body;
|
107 |
+
$mails[$i]["datetime_boost"] = $date;
|
108 |
+
}
|
109 |
+
else //creation
|
110 |
+
{
|
111 |
+
$mails[$i]["datetime"] = $date;
|
112 |
+
$header = $this->getHeaderMessage ($recipient_firstname, $recipient_lastname);
|
113 |
+
$htmlMessage = $header."<br/><br/>".$body;
|
114 |
+
}
|
115 |
+
|
116 |
+
$textMessage = $this->htmlToText($htmlMessage);
|
117 |
+
$mails[$i]["html_message"] = $htmlMessage;
|
118 |
+
$mails[$i]["text_message"] = $textMessage;
|
119 |
+
$htmlFooter = $this->getFooterMessage($sender_id, $recipient_firstname, $recipient_lastname, $recipient_email);
|
120 |
+
$mails[$i]["sponsorship_url"] = $this->getSponsorUrl($sender_id, $recipient_firstname, $recipient_lastname, $recipient_email);
|
121 |
+
$textFooter = $this->htmlToText($htmlFooter);
|
122 |
+
$mails[$i]["html_footer"] = $htmlFooter;
|
123 |
+
$mails[$i]["text_footer"] = $textFooter;
|
124 |
+
|
125 |
+
$i++;
|
126 |
+
}
|
127 |
+
return $mails;
|
128 |
+
}
|
129 |
+
public function validateMail($mails)
|
130 |
+
{
|
131 |
+
$valid = true;
|
132 |
+
foreach ($mails as $mail)
|
133 |
+
{
|
134 |
+
//Sender
|
135 |
+
$sender_name = $mail['sender_name'];
|
136 |
+
$sender_email = $mail['sender_email'];
|
137 |
+
|
138 |
+
//Recipient
|
139 |
+
$recipient_email = $mail['recipient_email'];
|
140 |
+
$recipient_firstname = $mail['recipient_firstname'];
|
141 |
+
$recipient_lastname = $mail['recipient_lastname'];
|
142 |
+
|
143 |
+
//Message
|
144 |
+
$textMessage = $mail['text_message'];
|
145 |
+
$subject = $mail['subject'];
|
146 |
+
|
147 |
+
if (!Zend_Validate::is(trim($sender_name) , 'NotEmpty')) {
|
148 |
+
$valid = false;
|
149 |
+
}
|
150 |
+
|
151 |
+
if (!Zend_Validate::is(trim($sender_email) , 'NotEmpty')) {
|
152 |
+
$valid = false;
|
153 |
+
}
|
154 |
+
|
155 |
+
if (!Zend_Validate::is(trim($sender_email), 'EmailAddress')) {
|
156 |
+
$valid = false;
|
157 |
+
}
|
158 |
+
|
159 |
+
if (!Zend_Validate::is(trim($textMessage) , 'NotEmpty')) {
|
160 |
+
$valid = false;
|
161 |
+
}
|
162 |
+
|
163 |
+
if (!Zend_Validate::is(trim($subject) , 'NotEmpty')) {
|
164 |
+
$valid = false;
|
165 |
+
}
|
166 |
+
|
167 |
+
if (!Zend_Validate::is(trim($recipient_email), 'EmailAddress')) {
|
168 |
+
$valid = false;
|
169 |
+
}
|
170 |
+
|
171 |
+
if (!Zend_Validate::is(trim($recipient_firstname) , 'NotEmpty')) {
|
172 |
+
|
173 |
+
$valid = false;
|
174 |
+
}
|
175 |
+
|
176 |
+
if (!Zend_Validate::is(trim($recipient_lastname) , 'NotEmpty')) {
|
177 |
+
|
178 |
+
$valid = false;
|
179 |
+
}
|
180 |
+
}
|
181 |
+
return $valid;
|
182 |
+
}
|
183 |
+
|
184 |
+
public function saveMail($mail)
|
185 |
+
{
|
186 |
+
try
|
187 |
+
{
|
188 |
+
$invit = "";
|
189 |
+
$data = Array();
|
190 |
+
//si sponsorship_id est envoyé : c'est un update
|
191 |
+
if (isset ($mail['sponsorship_id']))
|
192 |
+
{
|
193 |
+
$invit = mage::getModel("sponsorship/sponsorship")->load($mail["sponsorship_id"]);
|
194 |
+
$data = $invit->getData();
|
195 |
+
$data["datetime_boost"] = $mail['datetime_boost'];
|
196 |
+
}
|
197 |
+
else
|
198 |
+
{
|
199 |
+
$invit = mage::getModel("sponsorship/sponsorship");
|
200 |
+
$data["datetime"] = $mail['datetime'];
|
201 |
+
}
|
202 |
+
$data["parent_id"] = $mail["sender_id"];
|
203 |
+
$data["child_mail"] = $mail["recipient_email"];
|
204 |
+
$data["child_firstname"] = $mail["recipient_firstname"];
|
205 |
+
$data["child_lastname"] = $mail["recipient_lastname"];
|
206 |
+
$data["message"] = $mail["text_message"];
|
207 |
+
$data["parent_mail"] = $mail["sender_email"];
|
208 |
+
$data["parent_name"] = $mail["sender_name"];
|
209 |
+
$data["subject"] = $mail["subject"];
|
210 |
+
|
211 |
+
$invit->setData($data);
|
212 |
+
$invit->save();
|
213 |
+
return true;
|
214 |
+
}
|
215 |
+
catch (Exception $e)
|
216 |
+
{
|
217 |
+
return false;
|
218 |
+
}
|
219 |
+
}
|
220 |
+
|
221 |
+
public function sendMail($mail)
|
222 |
+
{
|
223 |
+
//generation du message en texte
|
224 |
+
$htmlMessage = $mail["html_message"];
|
225 |
+
$textMessage = $mail["text_message"];
|
226 |
+
$htmlFooter = $mail["html_footer"];
|
227 |
+
$textFooter = $mail["text_footer"];
|
228 |
+
$sender_name = $mail["sender_name"];
|
229 |
+
$sender_email = $mail["sender_email"];
|
230 |
+
$sender = array("name"=>$sender_name, "email"=>$sender_email);
|
231 |
+
$recipient_email = $mail["recipient_email"];
|
232 |
+
$recipient = $mail["recipient_firstname"]." ".$mail["recipient_lastname"];
|
233 |
+
|
234 |
+
$mailTemplate = Mage::getModel('sponsorship/Core_Email_Template');
|
235 |
+
|
236 |
+
$postObject = new Varien_Object();
|
237 |
+
$postObject->setData(Array ("sender_name" => $sender_name,
|
238 |
+
"sender_email" => $sender_email,
|
239 |
+
"subject" => $mail["subject"],
|
240 |
+
"html_message" => $htmlMessage,
|
241 |
+
"text_message" => $textMessage,
|
242 |
+
"html_footer" => $htmlFooter,
|
243 |
+
"text_footer" => $textFooter,
|
244 |
+
"recipient_email" => $recipient_email,
|
245 |
+
"sponsorship_url" => $mail["sponsorship_url"]
|
246 |
+
));
|
247 |
+
|
248 |
+
$mailTemplate->setDesignConfig(array('area' => 'fronted'))
|
249 |
+
->setReplyTo($sender_email)
|
250 |
+
->setReturnPath($sender_email)
|
251 |
+
->sendTransactional(
|
252 |
+
Mage::getStoreConfig('sponsorship/invitation_email/email_template'),
|
253 |
+
$sender,
|
254 |
+
$recipient_email,
|
255 |
+
$recipient,
|
256 |
+
array('data' => $postObject
|
257 |
+
));
|
258 |
+
if ($mailTemplate->getSentSuccess())
|
259 |
+
{
|
260 |
+
return true;
|
261 |
+
}
|
262 |
+
else
|
263 |
+
{
|
264 |
+
return false;
|
265 |
+
}
|
266 |
+
}
|
267 |
+
}
|
app/code/community/Auguria/Sponsorship/Lib/Html2Text.php
ADDED
@@ -0,0 +1,397 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/*************************************************************************
|
3 |
+
* *
|
4 |
+
* class.html2text.inc *
|
5 |
+
* *
|
6 |
+
*************************************************************************
|
7 |
+
* *
|
8 |
+
* Converts HTML to formatted plain text *
|
9 |
+
* *
|
10 |
+
* Copyright (c) 2005-2007 Jon Abernathy <jon@chuggnutt.com> *
|
11 |
+
* All rights reserved. *
|
12 |
+
* *
|
13 |
+
* This script is free software; you can redistribute it and/or modify *
|
14 |
+
* it under the terms of the GNU General Public License as published by *
|
15 |
+
* the Free Software Foundation; either version 2 of the License, or *
|
16 |
+
* (at your option) any later version. *
|
17 |
+
* *
|
18 |
+
* The GNU General Public License can be found at *
|
19 |
+
* http://www.gnu.org/copyleft/gpl.html. *
|
20 |
+
* *
|
21 |
+
* This script is distributed in the hope that it will be useful, *
|
22 |
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
23 |
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
24 |
+
* GNU General Public License for more details. *
|
25 |
+
* *
|
26 |
+
* Author(s): Jon Abernathy <jon@chuggnutt.com> *
|
27 |
+
* *
|
28 |
+
* Last modified: 08/08/07 *
|
29 |
+
* *
|
30 |
+
*************************************************************************/
|
31 |
+
|
32 |
+
|
33 |
+
/**
|
34 |
+
* Takes HTML and converts it to formatted, plain text.
|
35 |
+
*
|
36 |
+
* Thanks to Alexander Krug (http://www.krugar.de/) to pointing out and
|
37 |
+
* correcting an error in the regexp search array. Fixed 7/30/03.
|
38 |
+
*
|
39 |
+
* Updated set_html() function's file reading mechanism, 9/25/03.
|
40 |
+
*
|
41 |
+
* Thanks to Joss Sanglier (http://www.dancingbear.co.uk/) for adding
|
42 |
+
* several more HTML entity codes to the $search and $replace arrays.
|
43 |
+
* Updated 11/7/03.
|
44 |
+
*
|
45 |
+
* Thanks to Darius Kasperavicius (http://www.dar.dar.lt/) for
|
46 |
+
* suggesting the addition of $allowed_tags and its supporting function
|
47 |
+
* (which I slightly modified). Updated 3/12/04.
|
48 |
+
*
|
49 |
+
* Thanks to Justin Dearing for pointing out that a replacement for the
|
50 |
+
* <TH> tag was missing, and suggesting an appropriate fix.
|
51 |
+
* Updated 8/25/04.
|
52 |
+
*
|
53 |
+
* Thanks to Mathieu Collas (http://www.myefarm.com/) for finding a
|
54 |
+
* display/formatting bug in the _build_link_list() function: email
|
55 |
+
* readers would show the left bracket and number ("[1") as part of the
|
56 |
+
* rendered email address.
|
57 |
+
* Updated 12/16/04.
|
58 |
+
*
|
59 |
+
* Thanks to Wojciech Bajon (http://histeria.pl/) for submitting code
|
60 |
+
* to handle relative links, which I hadn't considered. I modified his
|
61 |
+
* code a bit to handle normal HTTP links and MAILTO links. Also for
|
62 |
+
* suggesting three additional HTML entity codes to search for.
|
63 |
+
* Updated 03/02/05.
|
64 |
+
*
|
65 |
+
* Thanks to Jacob Chandler for pointing out another link condition
|
66 |
+
* for the _build_link_list() function: "https".
|
67 |
+
* Updated 04/06/05.
|
68 |
+
*
|
69 |
+
* Thanks to Marc Bertrand (http://www.dresdensky.com/) for
|
70 |
+
* suggesting a revision to the word wrapping functionality; if you
|
71 |
+
* specify a $width of 0 or less, word wrapping will be ignored.
|
72 |
+
* Updated 11/02/06.
|
73 |
+
*
|
74 |
+
* *** Big housecleaning updates below:
|
75 |
+
*
|
76 |
+
* Thanks to Colin Brown (http://www.sparkdriver.co.uk/) for
|
77 |
+
* suggesting the fix to handle </li> and blank lines (whitespace).
|
78 |
+
* Christian Basedau (http://www.movetheweb.de/) also suggested the
|
79 |
+
* blank lines fix.
|
80 |
+
*
|
81 |
+
* Special thanks to Marcus Bointon (http://www.synchromedia.co.uk/),
|
82 |
+
* Christian Basedau, Norbert Laposa (http://ln5.co.uk/),
|
83 |
+
* Bas van de Weijer, and Marijn van Butselaar
|
84 |
+
* for pointing out my glaring error in the <th> handling. Marcus also
|
85 |
+
* supplied a host of fixes.
|
86 |
+
*
|
87 |
+
* Thanks to Jeffrey Silverman (http://www.newtnotes.com/) for pointing
|
88 |
+
* out that extra spaces should be compressed--a problem addressed with
|
89 |
+
* Marcus Bointon's fixes but that I had not yet incorporated.
|
90 |
+
*
|
91 |
+
* Thanks to Daniel Schledermann (http://www.typoconsult.dk/) for
|
92 |
+
* suggesting a valuable fix with <a> tag handling.
|
93 |
+
*
|
94 |
+
* Thanks to Wojciech Bajon (again!) for suggesting fixes and additions,
|
95 |
+
* including the <a> tag handling that Daniel Schledermann pointed
|
96 |
+
* out but that I had not yet incorporated. I haven't (yet)
|
97 |
+
* incorporated all of Wojciech's changes, though I may at some
|
98 |
+
* future time.
|
99 |
+
*
|
100 |
+
* *** End of the housecleaning updates. Updated 08/08/07.
|
101 |
+
*
|
102 |
+
* @author Jon Abernathy <jon@chuggnutt.com>
|
103 |
+
* @version 1.0.0
|
104 |
+
* @since PHP 4.0.2
|
105 |
+
*/
|
106 |
+
class Auguria_Sponsorship_Lib_Html2Text
|
107 |
+
{
|
108 |
+
|
109 |
+
var $html;
|
110 |
+
var $text;
|
111 |
+
var $width = 70;
|
112 |
+
var $search = array(
|
113 |
+
"/\r/", // Non-legal carriage return
|
114 |
+
"/[\n\t]+/", // Newlines and tabs
|
115 |
+
'/[ ]{2,}/', // Runs of spaces, pre-handling
|
116 |
+
'/<script[^>]*>.*?<\/script>/i', // <script>s -- which strip_tags supposedly has problems with
|
117 |
+
'/<style[^>]*>.*?<\/style>/i', // <style>s -- which strip_tags supposedly has problems with
|
118 |
+
//'/<!-- .* -->/', // Comments -- which strip_tags might have problem a with
|
119 |
+
'/<h[123][^>]*>(.*?)<\/h[123]>/ie', // H1 - H3
|
120 |
+
'/<h[456][^>]*>(.*?)<\/h[456]>/ie', // H4 - H6
|
121 |
+
'/<p[^>]*>/i', // <P>
|
122 |
+
'/<br[^>]*>/i', // <br>
|
123 |
+
'/<b[^>]*>(.*?)<\/b>/ie', // <b>
|
124 |
+
'/<strong[^>]*>(.*?)<\/strong>/ie', // <strong>
|
125 |
+
'/<i[^>]*>(.*?)<\/i>/i', // <i>
|
126 |
+
'/<em[^>]*>(.*?)<\/em>/i', // <em>
|
127 |
+
'/(<ul[^>]*>|<\/ul>)/i', // <ul> and </ul>
|
128 |
+
'/(<ol[^>]*>|<\/ol>)/i', // <ol> and </ol>
|
129 |
+
'/<li[^>]*>(.*?)<\/li>/i', // <li> and </li>
|
130 |
+
'/<li[^>]*>/i', // <li>
|
131 |
+
'/<a [^>]*href="([^"]+)"[^>]*>(.*?)<\/a>/ie',
|
132 |
+
// <a href="">
|
133 |
+
'/<hr[^>]*>/i', // <hr>
|
134 |
+
'/(<table[^>]*>|<\/table>)/i', // <table> and </table>
|
135 |
+
'/(<tr[^>]*>|<\/tr>)/i', // <tr> and </tr>
|
136 |
+
'/<td[^>]*>(.*?)<\/td>/i', // <td> and </td>
|
137 |
+
'/<th[^>]*>(.*?)<\/th>/ie', // <th> and </th>
|
138 |
+
'/&(nbsp|#160);/i', // Non-breaking space
|
139 |
+
'/&(quot|rdquo|ldquo|#8220|#8221|#147|#148);/i',
|
140 |
+
// Double quotes
|
141 |
+
'/&(apos|rsquo|lsquo|#8216|#8217);/i', // Single quotes
|
142 |
+
'/>/i', // Greater-than
|
143 |
+
'/</i', // Less-than
|
144 |
+
'/&(amp|#38);/i', // Ampersand
|
145 |
+
'/&(copy|#169);/i', // Copyright
|
146 |
+
'/&(trade|#8482|#153);/i', // Trademark
|
147 |
+
'/&(reg|#174);/i', // Registered
|
148 |
+
'/&(mdash|#151|#8212);/i', // mdash
|
149 |
+
'/&(ndash|minus|#8211|#8722);/i', // ndash
|
150 |
+
'/&(bull|#149|#8226);/i', // Bullet
|
151 |
+
'/&(pound|#163);/i', // Pound sign
|
152 |
+
'/&(euro|#8364);/i', // Euro sign
|
153 |
+
'/&[^&;]+;/i', // Unknown/unhandled entities
|
154 |
+
'/[ ]{2,}/' // Runs of spaces, post-handling
|
155 |
+
);
|
156 |
+
|
157 |
+
var $replace = array(
|
158 |
+
'', // Non-legal carriage return
|
159 |
+
' ', // Newlines and tabs
|
160 |
+
' ', // Runs of spaces, pre-handling
|
161 |
+
'', // <script>s -- which strip_tags supposedly has problems with
|
162 |
+
'', // <style>s -- which strip_tags supposedly has problems with
|
163 |
+
//'', // Comments -- which strip_tags might have problem a with
|
164 |
+
"strtoupper(\"\n\n\\1\n\n\")", // H1 - H3
|
165 |
+
"ucwords(\"\n\n\\1\n\n\")", // H4 - H6
|
166 |
+
"\n\n\t", // <P>
|
167 |
+
"\n", // <br>
|
168 |
+
'strtoupper("\\1")', // <b>
|
169 |
+
'strtoupper("\\1")', // <strong>
|
170 |
+
'_\\1_', // <i>
|
171 |
+
'_\\1_', // <em>
|
172 |
+
"\n\n", // <ul> and </ul>
|
173 |
+
"\n\n", // <ol> and </ol>
|
174 |
+
"\t* \\1\n", // <li> and </li>
|
175 |
+
"\n\t* ", // <li>
|
176 |
+
'$this->_build_link_list("\\1", "\\2")',
|
177 |
+
// <a href="">
|
178 |
+
"\n-------------------------\n", // <hr>
|
179 |
+
"\n\n", // <table> and </table>
|
180 |
+
"\n", // <tr> and </tr>
|
181 |
+
"\t\t\\1\n", // <td> and </td>
|
182 |
+
"strtoupper(\"\t\t\\1\n\")", // <th> and </th>
|
183 |
+
' ', // Non-breaking space
|
184 |
+
'"', // Double quotes
|
185 |
+
"'", // Single quotes
|
186 |
+
'>',
|
187 |
+
'<',
|
188 |
+
'&',
|
189 |
+
'(c)',
|
190 |
+
'(tm)',
|
191 |
+
'(R)',
|
192 |
+
'--',
|
193 |
+
'-',
|
194 |
+
'*',
|
195 |
+
'£',
|
196 |
+
'EUR', // Euro sign. € ?
|
197 |
+
'', // Unknown/unhandled entities
|
198 |
+
' ' // Runs of spaces, post-handling
|
199 |
+
);
|
200 |
+
|
201 |
+
var $allowed_tags = '';
|
202 |
+
var $url;
|
203 |
+
var $_converted = false;
|
204 |
+
var $_link_list = '';
|
205 |
+
var $_link_count = 0;
|
206 |
+
|
207 |
+
function Auguria_Sponsorship_Lib_Html2Text( $source = '', $from_file = false )
|
208 |
+
{
|
209 |
+
if ( !empty($source) ) {
|
210 |
+
$this->set_html($source, $from_file);
|
211 |
+
}
|
212 |
+
$this->set_base_url();
|
213 |
+
}
|
214 |
+
|
215 |
+
/**
|
216 |
+
* Loads source HTML into memory, either from $source string or a file.
|
217 |
+
*
|
218 |
+
* @param string $source HTML content
|
219 |
+
* @param boolean $from_file Indicates $source is a file to pull content from
|
220 |
+
* @access public
|
221 |
+
* @return void
|
222 |
+
*/
|
223 |
+
function set_html( $source, $from_file = false )
|
224 |
+
{
|
225 |
+
$this->html = $source;
|
226 |
+
|
227 |
+
if ( $from_file && file_exists($source) ) {
|
228 |
+
$fp = fopen($source, 'r');
|
229 |
+
$this->html = fread($fp, filesize($source));
|
230 |
+
fclose($fp);
|
231 |
+
}
|
232 |
+
|
233 |
+
$this->_converted = false;
|
234 |
+
}
|
235 |
+
|
236 |
+
/**
|
237 |
+
* Returns the text, converted from HTML.
|
238 |
+
*
|
239 |
+
* @access public
|
240 |
+
* @return string
|
241 |
+
*/
|
242 |
+
function get_text()
|
243 |
+
{
|
244 |
+
if ( !$this->_converted ) {
|
245 |
+
$this->_convert();
|
246 |
+
}
|
247 |
+
|
248 |
+
return $this->text;
|
249 |
+
}
|
250 |
+
|
251 |
+
/**
|
252 |
+
* Prints the text, converted from HTML.
|
253 |
+
*
|
254 |
+
* @access public
|
255 |
+
* @return void
|
256 |
+
*/
|
257 |
+
function print_text()
|
258 |
+
{
|
259 |
+
print $this->get_text();
|
260 |
+
}
|
261 |
+
|
262 |
+
/**
|
263 |
+
* Alias to print_text(), operates identically.
|
264 |
+
*
|
265 |
+
* @access public
|
266 |
+
* @return void
|
267 |
+
* @see print_text()
|
268 |
+
*/
|
269 |
+
function p()
|
270 |
+
{
|
271 |
+
print $this->get_text();
|
272 |
+
}
|
273 |
+
|
274 |
+
/**
|
275 |
+
* Sets the allowed HTML tags to pass through to the resulting text.
|
276 |
+
*
|
277 |
+
* Tags should be in the form "<p>", with no corresponding closing tag.
|
278 |
+
*
|
279 |
+
* @access public
|
280 |
+
* @return void
|
281 |
+
*/
|
282 |
+
function set_allowed_tags( $allowed_tags = '' )
|
283 |
+
{
|
284 |
+
if ( !empty($allowed_tags) ) {
|
285 |
+
$this->allowed_tags = $allowed_tags;
|
286 |
+
}
|
287 |
+
}
|
288 |
+
|
289 |
+
/**
|
290 |
+
* Sets a base URL to handle relative links.
|
291 |
+
*
|
292 |
+
* @access public
|
293 |
+
* @return void
|
294 |
+
*/
|
295 |
+
function set_base_url( $url = '' )
|
296 |
+
{
|
297 |
+
if ( empty($url) ) {
|
298 |
+
if ( !empty($_SERVER['HTTP_HOST']) ) {
|
299 |
+
$this->url = 'http://' . $_SERVER['HTTP_HOST'];
|
300 |
+
} else {
|
301 |
+
$this->url = '';
|
302 |
+
}
|
303 |
+
} else {
|
304 |
+
// Strip any trailing slashes for consistency (relative
|
305 |
+
// URLs may already start with a slash like "/file.html")
|
306 |
+
if ( substr($url, -1) == '/' ) {
|
307 |
+
$url = substr($url, 0, -1);
|
308 |
+
}
|
309 |
+
$this->url = $url;
|
310 |
+
}
|
311 |
+
}
|
312 |
+
|
313 |
+
/**
|
314 |
+
* Workhorse function that does actual conversion.
|
315 |
+
*
|
316 |
+
* First performs custom tag replacement specified by $search and
|
317 |
+
* $replace arrays. Then strips any remaining HTML tags, reduces whitespace
|
318 |
+
* and newlines to a readable format, and word wraps the text to
|
319 |
+
* $width characters.
|
320 |
+
*
|
321 |
+
* @access private
|
322 |
+
* @return void
|
323 |
+
*/
|
324 |
+
function _convert()
|
325 |
+
{
|
326 |
+
// Variables used for building the link list
|
327 |
+
$this->_link_count = 0;
|
328 |
+
$this->_link_list = '';
|
329 |
+
|
330 |
+
$text = trim(stripslashes($this->html));
|
331 |
+
|
332 |
+
// Run our defined search-and-replace
|
333 |
+
$text = preg_replace($this->search, $this->replace, $text);
|
334 |
+
|
335 |
+
// Strip any other HTML tags
|
336 |
+
$text = strip_tags($text, $this->allowed_tags);
|
337 |
+
|
338 |
+
// Bring down number of empty lines to 2 max
|
339 |
+
$text = preg_replace("/\n\s+\n/", "\n\n", $text);
|
340 |
+
$text = preg_replace("/[\n]{3,}/", "\n\n", $text);
|
341 |
+
|
342 |
+
// Add link list
|
343 |
+
if ( !empty($this->_link_list) ) {
|
344 |
+
$text .= "\n\nLinks:\n------\n" . $this->_link_list;
|
345 |
+
}
|
346 |
+
|
347 |
+
// Wrap the text to a readable format
|
348 |
+
// for PHP versions >= 4.0.2. Default width is 75
|
349 |
+
// If width is 0 or less, don't wrap the text.
|
350 |
+
if ( $this->width > 0 ) {
|
351 |
+
$text = wordwrap($text, $this->width);
|
352 |
+
}
|
353 |
+
|
354 |
+
$this->text = $text;
|
355 |
+
|
356 |
+
$this->_converted = true;
|
357 |
+
}
|
358 |
+
|
359 |
+
/**
|
360 |
+
* Helper function called by preg_replace() on link replacement.
|
361 |
+
*
|
362 |
+
* Maintains an internal list of links to be displayed at the end of the
|
363 |
+
* text, with numeric indices to the original point in the text they
|
364 |
+
* appeared. Also makes an effort at identifying and handling absolute
|
365 |
+
* and relative links.
|
366 |
+
*
|
367 |
+
* @param string $link URL of the link
|
368 |
+
* @param string $display Part of the text to associate number with
|
369 |
+
* @access private
|
370 |
+
* @return string
|
371 |
+
*/
|
372 |
+
function _build_link_list( $link, $display )
|
373 |
+
{
|
374 |
+
if ( substr($link, 0, 7) == 'http://' || substr($link, 0, 8) == 'https://' ||
|
375 |
+
substr($link, 0, 7) == 'mailto:' ) {
|
376 |
+
$this->_link_count++;
|
377 |
+
$this->_link_list .= "[" . $this->_link_count . "] $link\n";
|
378 |
+
$additional = ' [' . $this->_link_count . ']';
|
379 |
+
} elseif ( substr($link, 0, 11) == 'javascript:' ) {
|
380 |
+
// Don't count the link; ignore it
|
381 |
+
$additional = '';
|
382 |
+
// what about href="#anchor" ?
|
383 |
+
} else {
|
384 |
+
$this->_link_count++;
|
385 |
+
$this->_link_list .= "[" . $this->_link_count . "] " . $this->url;
|
386 |
+
if ( substr($link, 0, 1) != '/' ) {
|
387 |
+
$this->_link_list .= '/';
|
388 |
+
}
|
389 |
+
$this->_link_list .= "$link\n";
|
390 |
+
$additional = ' [' . $this->_link_count . ']';
|
391 |
+
}
|
392 |
+
|
393 |
+
return $display . $additional;
|
394 |
+
}
|
395 |
+
|
396 |
+
}
|
397 |
+
?>
|
app/code/community/Auguria/Sponsorship/Model/Adminhtml/System/Config/Backend/Sponsorship/Entier.php
ADDED
@@ -0,0 +1,25 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* @category Auguria
|
4 |
+
* @package Auguria_Sponsorship
|
5 |
+
* @author Auguria
|
6 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
7 |
+
*/
|
8 |
+
class Auguria_Sponsorship_Model_Adminhtml_System_Config_Backend_Sponsorship_Entier extends Mage_Core_Model_Config_Data
|
9 |
+
{
|
10 |
+
protected function _beforeSave()
|
11 |
+
{
|
12 |
+
$value = $this->getValue();
|
13 |
+
if (!Zend_Validate::is($value, 'NotEmpty')) {
|
14 |
+
Mage::throwException(Mage::helper('sponsorship')->__("A value is required."));
|
15 |
+
}
|
16 |
+
if (!Zend_Validate::is($value, 'Digits')) {
|
17 |
+
Mage::throwException(Mage::helper('sponsorship')->__("'%s' is not an integer.", $value));
|
18 |
+
}
|
19 |
+
$validator = new Zend_Validate_GreaterThan(0);
|
20 |
+
if (!$validator->isValid($value)) {
|
21 |
+
Mage::throwException(Mage::helper('sponsorship')->__("'%s' is not greater than 0.", $value));
|
22 |
+
}
|
23 |
+
return $this;
|
24 |
+
}
|
25 |
+
}
|
app/code/community/Auguria/Sponsorship/Model/Adminhtml/System/Config/Backend/Sponsorship/Float.php
ADDED
@@ -0,0 +1,26 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* @category Auguria
|
4 |
+
* @package Auguria_Sponsorship
|
5 |
+
* @author Auguria
|
6 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
7 |
+
*/
|
8 |
+
class Auguria_Sponsorship_Model_Adminhtml_System_Config_Backend_Sponsorship_Float extends Mage_Core_Model_Config_Data
|
9 |
+
{
|
10 |
+
protected function _beforeSave()
|
11 |
+
{
|
12 |
+
$value = $this->getValue();
|
13 |
+
if (!Zend_Validate::is($value, 'NotEmpty')) {
|
14 |
+
Mage::throwException(Mage::helper('sponsorship')->__("A value is required."));
|
15 |
+
}
|
16 |
+
$validator = new Zend_Validate_Regex('/^[-+]?[0-9]*\.?[0-9]{0,4}$/');
|
17 |
+
if (!$validator->isValid($value)) {
|
18 |
+
Mage::throwException(Mage::helper('sponsorship')->__("'%s' is not a valid number.", $value));
|
19 |
+
}
|
20 |
+
$validator = new Zend_Validate_GreaterThan(0);
|
21 |
+
if (!$validator->isValid($value)) {
|
22 |
+
Mage::throwException(Mage::helper('sponsorship')->__("'%s' is not greater than 0.", $value));
|
23 |
+
}
|
24 |
+
return $this;
|
25 |
+
}
|
26 |
+
}
|
app/code/community/Auguria/Sponsorship/Model/AutoBoost.php
ADDED
@@ -0,0 +1,63 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* @category Auguria
|
4 |
+
* @package Auguria_Sponsorship
|
5 |
+
* @author Auguria
|
6 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
7 |
+
*/
|
8 |
+
class Auguria_Sponsorship_Model_AutoBoost
|
9 |
+
{
|
10 |
+
public function process ()
|
11 |
+
{
|
12 |
+
/*
|
13 |
+
* Selection des invitations n'ayant pas été relancées
|
14 |
+
* Suivant les paramètres de délai avant relance et de validité des invitations
|
15 |
+
*/
|
16 |
+
$resource = Mage::getSingleton('core/resource');
|
17 |
+
$read = $resource->getConnection('core_read');
|
18 |
+
$select = $read->select()
|
19 |
+
->from(Array("s"=>$resource->getTableName('sponsorship/sponsorship')),
|
20 |
+
Array("*"=>"s.*"))
|
21 |
+
->where('isnull(datetime_boost)')
|
22 |
+
->where('TO_DAYS(NOW()) - TO_DAYS(datetime) >= ?', Mage::getStoreConfig('sponsorship/invitation_email/time_before_boost'))
|
23 |
+
->where('TO_DAYS(NOW()) - TO_DAYS(datetime) <= ?', Mage::getStoreConfig('sponsorship/invitation_email/sponsor_invitation_validity'));
|
24 |
+
|
25 |
+
$resultats = $read->fetchAll($select);
|
26 |
+
foreach ($resultats as $resultat)
|
27 |
+
{
|
28 |
+
$mailHelper = mage::helper("sponsorship/mail");
|
29 |
+
$mail["sponsorship_id"] = $resultat["sponsorship_id"];
|
30 |
+
$mail["subject"] = $resultat["subject"];
|
31 |
+
$mail["html_message"] = $resultat["message"];
|
32 |
+
$mail["text_message"] = $mailHelper->htmlToText($resultat["message"]);
|
33 |
+
|
34 |
+
$mail["html_footer"] = $mailHelper->getFooterMessage($resultat["parent_id"], $resultat["child_firstname"], $resultat["child_lastname"], $resultat["child_mail"]);
|
35 |
+
$mail["text_footer"] = $mailHelper->htmlToText($mail["html_footer"]);
|
36 |
+
|
37 |
+
$mail["sponsorship_url"] = $mailHelper->getSponsorUrl($resultat["parent_id"], $resultat["child_firstname"], $resultat["child_lastname"], $resultat["child_mail"]);
|
38 |
+
|
39 |
+
$mail["sender_name"] = $resultat["parent_name"];
|
40 |
+
$mail["sender_email"] = $resultat["parent_mail"];
|
41 |
+
$mail["sender_id"] = $resultat["parent_id"];
|
42 |
+
$mail["recipient_email"] = $resultat["child_mail"];
|
43 |
+
$mail["recipient_firstname"] = $resultat["child_firstname"];
|
44 |
+
$mail["recipient_lastname"] = $resultat["child_lastname"];
|
45 |
+
$mail['datetime_boost'] = now();
|
46 |
+
|
47 |
+
if ($mailHelper->sendMail($mail))
|
48 |
+
{
|
49 |
+
try
|
50 |
+
{
|
51 |
+
$sponsorship = mage::getModel("sponsorship/sponsorship")->load($mail["sponsorship_id"]);
|
52 |
+
$sponsorship->setDatetimeBoost($mail['datetime_boost']);
|
53 |
+
$sponsorship->save();
|
54 |
+
mage::log("1 mail sent by autoboost");
|
55 |
+
}
|
56 |
+
catch (Exception $e)
|
57 |
+
{
|
58 |
+
mage::log($e);
|
59 |
+
}
|
60 |
+
}
|
61 |
+
}
|
62 |
+
}
|
63 |
+
}
|
app/code/community/Auguria/Sponsorship/Model/Change.php
ADDED
@@ -0,0 +1,15 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* @category Auguria
|
4 |
+
* @package Auguria_Sponsorship
|
5 |
+
* @author Auguria
|
6 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
7 |
+
*/
|
8 |
+
class Auguria_Sponsorship_Model_Change extends Mage_Core_Model_Abstract
|
9 |
+
{
|
10 |
+
public function _construct()
|
11 |
+
{
|
12 |
+
parent::_construct();
|
13 |
+
$this->_init('sponsorship/change');
|
14 |
+
}
|
15 |
+
}
|
app/code/community/Auguria/Sponsorship/Model/Changestatut.php
ADDED
@@ -0,0 +1,24 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* @category Auguria
|
4 |
+
* @package Auguria_Sponsorship
|
5 |
+
* @author Auguria
|
6 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
7 |
+
*/
|
8 |
+
class Auguria_Sponsorship_Model_Changestatut extends Varien_Object
|
9 |
+
{
|
10 |
+
const STATUS_WAITING = 'waiting';
|
11 |
+
const STATUS_EXPORTED = 'exported';
|
12 |
+
const STATUS_SOLVED = 'solved';
|
13 |
+
const STATUS_CANCELED = 'canceled';
|
14 |
+
|
15 |
+
static public function getOptionArray()
|
16 |
+
{
|
17 |
+
return array(
|
18 |
+
self::STATUS_WAITING => Mage::helper('sponsorship')->__('Waiting'),
|
19 |
+
self::STATUS_EXPORTED => Mage::helper('sponsorship')->__('Exported'),
|
20 |
+
self::STATUS_SOLVED => Mage::helper('sponsorship')->__('Solved'),
|
21 |
+
self::STATUS_CANCELED => Mage::helper('sponsorship')->__('Canceled')
|
22 |
+
);
|
23 |
+
}
|
24 |
+
}
|
app/code/community/Auguria/Sponsorship/Model/Core/Email/Template.php
ADDED
@@ -0,0 +1,68 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* @category Auguria
|
4 |
+
* @package Auguria_Sponsorship
|
5 |
+
* @author Auguria
|
6 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
7 |
+
*/
|
8 |
+
class Auguria_Sponsorship_Model_Core_Email_Template extends Mage_Core_Model_Email_Template
|
9 |
+
{
|
10 |
+
public function send($email, $name=null, array $variables = array())
|
11 |
+
{
|
12 |
+
if(!$this->isValidForSend()) {
|
13 |
+
return false;
|
14 |
+
}
|
15 |
+
|
16 |
+
if (is_null($name)) {
|
17 |
+
$name = substr($email, 0, strpos($email, '@'));
|
18 |
+
}
|
19 |
+
|
20 |
+
$variables['email'] = $email;
|
21 |
+
$variables['name'] = $name;
|
22 |
+
|
23 |
+
ini_set('SMTP', Mage::getStoreConfig('system/smtp/host'));
|
24 |
+
ini_set('smtp_port', Mage::getStoreConfig('system/smtp/port'));
|
25 |
+
|
26 |
+
$mail = $this->getMail();
|
27 |
+
if (is_array($email)) {
|
28 |
+
foreach ($email as $emailOne) {
|
29 |
+
$mail->addTo($emailOne, $name);
|
30 |
+
}
|
31 |
+
} else {
|
32 |
+
$mail->addTo($email, '=?utf-8?B?'.base64_encode($name).'?=');
|
33 |
+
}
|
34 |
+
|
35 |
+
$this->setUseAbsoluteLinks(true);
|
36 |
+
$text = $this->getProcessedTemplate($variables, true);
|
37 |
+
|
38 |
+
$boundary = '--BOUNDARY_TEXT_OF_CHOICE_FOR_AUGURIA_SPONSORSHIP';
|
39 |
+
|
40 |
+
$boundary_location = strpos($text, $boundary);
|
41 |
+
if ($boundary_location) {
|
42 |
+
$stext = substr($text, 0, strpos($text, $boundary));
|
43 |
+
$shtml = str_replace($boundary, '', substr($text, $boundary_location));
|
44 |
+
$mail->setBodyText($stext);
|
45 |
+
$mail->setBodyHTML($shtml);
|
46 |
+
} else {
|
47 |
+
if($this->isPlain()) {
|
48 |
+
$mail->setBodyText($text);
|
49 |
+
} else {
|
50 |
+
$mail->setBodyHTML($text);
|
51 |
+
}
|
52 |
+
}
|
53 |
+
|
54 |
+
|
55 |
+
$mail->setSubject('=?utf-8?B?'.base64_encode($this->getProcessedTemplateSubject($variables)).'?=');
|
56 |
+
$mail->setFrom($this->getSenderEmail(), $this->getSenderName());
|
57 |
+
|
58 |
+
try {
|
59 |
+
$mail->send(); // Zend_Mail warning..
|
60 |
+
$this->_mail = null;
|
61 |
+
}
|
62 |
+
catch (Exception $e) {
|
63 |
+
return false;
|
64 |
+
}
|
65 |
+
|
66 |
+
return true;
|
67 |
+
}
|
68 |
+
}
|
app/code/community/Auguria/Sponsorship/Model/Customer/Customer.php
ADDED
@@ -0,0 +1,112 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* @category Auguria
|
4 |
+
* @package Auguria_Sponsorship
|
5 |
+
* @author Auguria
|
6 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
7 |
+
*/
|
8 |
+
class Auguria_Sponsorship_Model_Customer_Customer extends Mage_Customer_Model_Customer
|
9 |
+
{
|
10 |
+
public function validate()
|
11 |
+
{
|
12 |
+
$errors = array();
|
13 |
+
if (Zend_Validate::is( trim($this->getIban()) , 'NotEmpty'))
|
14 |
+
if (!Zend_Validate::is( trim($this->getIban()) , 'Iban')) {
|
15 |
+
$errors[] = Mage::helper('sponsorship')->__('Invalid IBAN code "%s"', $this->getIban());
|
16 |
+
}
|
17 |
+
/*
|
18 |
+
* Vérification du SIRET désactivé pour internationalisation
|
19 |
+
if ($siret = $this->getSiret()) {
|
20 |
+
if (!$this->isSiret(trim($siret))) {
|
21 |
+
$errors[] = Mage::helper('customer')->__('Invalid SIRET code');
|
22 |
+
}
|
23 |
+
}
|
24 |
+
*
|
25 |
+
*/
|
26 |
+
|
27 |
+
if (!Zend_Validate::is( trim($this->getFirstname()) , 'NotEmpty')) {
|
28 |
+
$errors[] = Mage::helper('customer')->__('First name can\'t be empty');
|
29 |
+
}
|
30 |
+
|
31 |
+
if (!Zend_Validate::is( trim($this->getLastname()) , 'NotEmpty')) {
|
32 |
+
$errors[] = Mage::helper('customer')->__('Last name can\'t be empty');
|
33 |
+
}
|
34 |
+
|
35 |
+
if (!Zend_Validate::is($this->getEmail(), 'EmailAddress')) {
|
36 |
+
$errors[] = Mage::helper('customer')->__('Invalid email address "%s"', $this->getEmail());
|
37 |
+
}
|
38 |
+
|
39 |
+
$password = $this->getPassword();
|
40 |
+
if (!$this->getId() && !Zend_Validate::is($password , 'NotEmpty')) {
|
41 |
+
$errors[] = Mage::helper('customer')->__('Password can\'t be empty');
|
42 |
+
}
|
43 |
+
if ($password && !Zend_Validate::is($password, 'StringLength', array(6))) {
|
44 |
+
$errors[] = Mage::helper('customer')->__('Password minimal length must be more %s', 6);
|
45 |
+
}
|
46 |
+
$confirmation = $this->getConfirmation();
|
47 |
+
if ($password != $confirmation) {
|
48 |
+
$errors[] = Mage::helper('customer')->__('Please make sure your passwords match.');
|
49 |
+
}
|
50 |
+
|
51 |
+
if (('req' === Mage::helper('customer/address')->getConfig('dob_show'))
|
52 |
+
&& '' == trim($this->getDob())) {
|
53 |
+
$errors[] = Mage::helper('customer')->__('Date of Birth is required.');
|
54 |
+
}
|
55 |
+
if (('req' === Mage::helper('customer/address')->getConfig('taxvat_show'))
|
56 |
+
&& '' == trim($this->getTaxvat())) {
|
57 |
+
$errors[] = Mage::helper('customer')->__('TAX/VAT number is required.');
|
58 |
+
}
|
59 |
+
|
60 |
+
if (empty($errors)) {
|
61 |
+
return true;
|
62 |
+
}
|
63 |
+
return $errors;
|
64 |
+
}
|
65 |
+
/*
|
66 |
+
* Vérification du SIRET désactivé pour internationalisation
|
67 |
+
public function isSiret ($siret)
|
68 |
+
{
|
69 |
+
$siret = str_replace ( ' ', '', $siret );
|
70 |
+
if (strlen ( $siret ) != 14 || !is_numeric ( $siret )) {
|
71 |
+
return false;
|
72 |
+
}
|
73 |
+
$siren = substr ( $siret, 0, 9 );
|
74 |
+
if (! $this->isSiren ( $siren )) {
|
75 |
+
return false;
|
76 |
+
}
|
77 |
+
$total = 0;
|
78 |
+
for($i = 0; $i < 14; $i++) {
|
79 |
+
$temp = substr ( $siret, $i, 1 );
|
80 |
+
if ($i % 2 == 0) {
|
81 |
+
$temp *= 2;
|
82 |
+
if ($temp > 9) {
|
83 |
+
$temp -= 9;
|
84 |
+
}
|
85 |
+
}
|
86 |
+
$total += $temp;
|
87 |
+
}
|
88 |
+
return (($total % 10) == 0);
|
89 |
+
}
|
90 |
+
|
91 |
+
function isSiren($siren)
|
92 |
+
{
|
93 |
+
$siren = str_replace ( ' ', '', $siren );
|
94 |
+
if (strlen ( $siren ) != 9 || !is_numeric ( $siren )) {
|
95 |
+
return false;
|
96 |
+
}
|
97 |
+
$total = 0;
|
98 |
+
for($i = 0; $i < 9; $i++) {
|
99 |
+
$temp = substr ( $siren, $i, 1 );
|
100 |
+
if ($i % 2 == 1) {
|
101 |
+
$temp *= 2;
|
102 |
+
if ($temp > 9) {
|
103 |
+
$temp -= 9;
|
104 |
+
}
|
105 |
+
}
|
106 |
+
$total += $temp;
|
107 |
+
}
|
108 |
+
return (($total % 10) == 0);
|
109 |
+
}
|
110 |
+
*
|
111 |
+
*/
|
112 |
+
}
|
app/code/community/Auguria/Sponsorship/Model/EmptyPHP.php
ADDED
@@ -0,0 +1,266 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
class test
|
3 |
+
{
|
4 |
+
public function process(Mage_Sales_Model_Quote_Item_Abstract $item)
|
5 |
+
{
|
6 |
+
$item->setFreeShipping(false);
|
7 |
+
$item->setDiscountAmount(0);
|
8 |
+
$item->setBaseDiscountAmount(0);
|
9 |
+
$item->setDiscountPercent(0);
|
10 |
+
$item->setCartFidelityPoints(0);
|
11 |
+
$item->setCartSponsorPoints(0);
|
12 |
+
|
13 |
+
$quote = $item->getQuote();
|
14 |
+
if ($item instanceof Mage_Sales_Model_Quote_Address_Item) {
|
15 |
+
$address = $item->getAddress();
|
16 |
+
} elseif ($quote->isVirtual()) {
|
17 |
+
$address = $quote->getBillingAddress();
|
18 |
+
} else {
|
19 |
+
$address = $quote->getShippingAddress();
|
20 |
+
}
|
21 |
+
|
22 |
+
$customerId = $quote->getCustomerId();
|
23 |
+
$ruleCustomer = Mage::getModel('salesrule/rule_customer');
|
24 |
+
$appliedRuleIds = array();
|
25 |
+
|
26 |
+
foreach ($this->_rules as $rule) {
|
27 |
+
/* @var $rule Mage_SalesRule_Model_Rule */
|
28 |
+
/**
|
29 |
+
* already tried to validate and failed
|
30 |
+
*/
|
31 |
+
if ($rule->getIsValid() === false) {
|
32 |
+
continue;
|
33 |
+
}
|
34 |
+
|
35 |
+
if ($rule->getIsValid() !== true) {
|
36 |
+
/**
|
37 |
+
* too many times used in general
|
38 |
+
*/
|
39 |
+
if ($rule->getUsesPerCoupon() && ($rule->getTimesUsed() >= $rule->getUsesPerCoupon())) {
|
40 |
+
$rule->setIsValid(false);
|
41 |
+
continue;
|
42 |
+
}
|
43 |
+
/**
|
44 |
+
* too many times used for this customer
|
45 |
+
*/
|
46 |
+
$ruleId = $rule->getId();
|
47 |
+
if ($ruleId && $rule->getUsesPerCustomer()) {
|
48 |
+
$ruleCustomer->loadByCustomerRule($customerId, $ruleId);
|
49 |
+
if ($ruleCustomer->getId()) {
|
50 |
+
if ($ruleCustomer->getTimesUsed() >= $rule->getUsesPerCustomer()) {
|
51 |
+
continue;
|
52 |
+
}
|
53 |
+
}
|
54 |
+
}
|
55 |
+
$rule->afterLoad();
|
56 |
+
/**
|
57 |
+
* quote does not meet rule's conditions
|
58 |
+
*/
|
59 |
+
if (!$rule->validate($address)) {
|
60 |
+
$rule->setIsValid(false);
|
61 |
+
continue;
|
62 |
+
}
|
63 |
+
/**
|
64 |
+
* passed all validations, remember to be valid
|
65 |
+
*/
|
66 |
+
$rule->setIsValid(true);
|
67 |
+
}
|
68 |
+
|
69 |
+
/**
|
70 |
+
* although the rule is valid, this item is not marked for action
|
71 |
+
*/
|
72 |
+
if (!$rule->getActions()->validate($item)) {
|
73 |
+
continue;
|
74 |
+
}
|
75 |
+
$qty = $item->getQty();
|
76 |
+
if ($item->getParentItem()) {
|
77 |
+
$qty*= $item->getParentItem()->getQty();
|
78 |
+
}
|
79 |
+
$qty = $rule->getDiscountQty() ? min($qty, $rule->getDiscountQty()) : $qty;
|
80 |
+
$rulePercent = min(100, $rule->getDiscountAmount());
|
81 |
+
$discountAmount = 0;
|
82 |
+
$baseDiscountAmount = 0;
|
83 |
+
$cartFidelityPoints = 0;
|
84 |
+
$cartSponsorPoints = 0;
|
85 |
+
switch ($rule->getSimpleAction()) {
|
86 |
+
case 'to_percent':
|
87 |
+
$rulePercent = max(0, 100-$rule->getDiscountAmount());
|
88 |
+
//no break;
|
89 |
+
|
90 |
+
case 'by_percent':
|
91 |
+
if ($step = $rule->getDiscountStep()) {
|
92 |
+
$qty = floor($qty/$step)*$step;
|
93 |
+
}
|
94 |
+
$discountAmount = ($qty*$item->getCalculationPrice() - $item->getDiscountAmount()) * $rulePercent/100;
|
95 |
+
$baseDiscountAmount= ($qty*$item->getBaseCalculationPrice() - $item->getBaseDiscountAmount()) * $rulePercent/100;
|
96 |
+
|
97 |
+
if (!$rule->getDiscountQty() || $rule->getDiscountQty()>$qty) {
|
98 |
+
$discountPercent = min(100, $item->getDiscountPercent()+$rulePercent);
|
99 |
+
$item->setDiscountPercent($discountPercent);
|
100 |
+
}
|
101 |
+
break;
|
102 |
+
|
103 |
+
case 'to_fixed':
|
104 |
+
$quoteAmount = $quote->getStore()->convertPrice($rule->getDiscountAmount());
|
105 |
+
$discountAmount = $qty*($item->getCalculationPrice()-$quoteAmount);
|
106 |
+
$baseDiscountAmount= $qty*($item->getBaseCalculationPrice()-$rule->getDiscountAmount());
|
107 |
+
break;
|
108 |
+
|
109 |
+
case 'by_fixed':
|
110 |
+
if ($step = $rule->getDiscountStep()) {
|
111 |
+
$qty = floor($qty/$step)*$step;
|
112 |
+
}
|
113 |
+
$quoteAmount = $quote->getStore()->convertPrice($rule->getDiscountAmount());
|
114 |
+
$discountAmount = $qty*$quoteAmount;
|
115 |
+
$baseDiscountAmount= $qty*$rule->getDiscountAmount();
|
116 |
+
break;
|
117 |
+
|
118 |
+
case 'cart_fixed':
|
119 |
+
$cartRules = $address->getCartFixedRules();
|
120 |
+
if (!isset($cartRules[$rule->getId()])) {
|
121 |
+
$cartRules[$rule->getId()] = $rule->getDiscountAmount();
|
122 |
+
}
|
123 |
+
if ($cartRules[$rule->getId()] > 0) {
|
124 |
+
$quoteAmount = $quote->getStore()->convertPrice($cartRules[$rule->getId()]);
|
125 |
+
$discountAmount = min($item->getRowTotal(), $quoteAmount);
|
126 |
+
$baseDiscountAmount = min($item->getBaseRowTotal(), $cartRules[$rule->getId()]);
|
127 |
+
$cartRules[$rule->getId()] -= $baseDiscountAmount;
|
128 |
+
}
|
129 |
+
$address->setCartFixedRules($cartRules);
|
130 |
+
break;
|
131 |
+
|
132 |
+
case 'buy_x_get_y':
|
133 |
+
$x = $rule->getDiscountStep();
|
134 |
+
$y = $rule->getDiscountAmount();
|
135 |
+
if (!$x || $y>=$x) {
|
136 |
+
break;
|
137 |
+
}
|
138 |
+
$buy = 0; $free = 0;
|
139 |
+
while ($buy+$free<$qty) {
|
140 |
+
$buy += $x;
|
141 |
+
if ($buy+$free>=$qty) {
|
142 |
+
break;
|
143 |
+
}
|
144 |
+
$free += min($y, $qty-$buy-$free);
|
145 |
+
if ($buy+$free>=$qty) {
|
146 |
+
break;
|
147 |
+
}
|
148 |
+
}
|
149 |
+
$discountAmount = $free*$item->getCalculationPrice();
|
150 |
+
$baseDiscountAmount= $free*$item->getBaseCalculationPrice();
|
151 |
+
break;
|
152 |
+
|
153 |
+
//début case perso-------------------------------------------------------------------
|
154 |
+
//fielity
|
155 |
+
case 'fidelity_points_by_fixed':
|
156 |
+
if ($step = $rule->getDiscountStep()) {
|
157 |
+
$qty = floor($qty/$step)*$step;
|
158 |
+
}
|
159 |
+
$cartFidelityPoints = $qty*$rule->getDiscountAmount();
|
160 |
+
break;
|
161 |
+
|
162 |
+
case 'fidelity_points_by_percent':
|
163 |
+
if ($step = $rule->getDiscountStep()) {
|
164 |
+
$qty = floor($qty/$step)*$step;
|
165 |
+
}
|
166 |
+
$cartFidelityPoints = ($qty * ($item->getBaseCalculationPrice() - $item->getBaseDiscountAmount())) * $rulePercent/100;
|
167 |
+
break;
|
168 |
+
|
169 |
+
case 'fidelity_points_cart_fixed':
|
170 |
+
$cartRules = $address->getCartFixedRules();
|
171 |
+
if (!isset($cartRules[$rule->getId()])) {
|
172 |
+
$cartRules[$rule->getId()] = $rule->getDiscountAmount();
|
173 |
+
}
|
174 |
+
if ($cartRules[$rule->getId()] > 0) {
|
175 |
+
$cartFidelityPoints = max($item->getCartFidelityPoints(), $cartRules[$rule->getId()]);
|
176 |
+
$cartRules[$rule->getId()] -= $cartFidelityPoints;
|
177 |
+
}
|
178 |
+
$address->setCartFixedRules($cartRules);
|
179 |
+
break;
|
180 |
+
//sponsor
|
181 |
+
case 'sponsor_points_by_fixed':
|
182 |
+
if ($step = $rule->getDiscountStep()) {
|
183 |
+
$qty = floor($qty/$step)*$step;
|
184 |
+
}
|
185 |
+
$cartSponsorPoints = $qty*$rule->getDiscountAmount();
|
186 |
+
break;
|
187 |
+
|
188 |
+
case 'sponsor_points_by_percent':
|
189 |
+
if ($step = $rule->getDiscountStep()) {
|
190 |
+
$qty = floor($qty/$step)*$step;
|
191 |
+
}
|
192 |
+
$cartSponsorPoints = ($qty * ($item->getBaseCalculationPrice() - $item->getBaseDiscountAmount())) * $rulePercent/100;
|
193 |
+
break;
|
194 |
+
|
195 |
+
case 'sponsor_points_cart_fixed':
|
196 |
+
$cartRules = $address->getCartFixedRules();
|
197 |
+
if (!isset($cartRules[$rule->getId()])) {
|
198 |
+
$cartRules[$rule->getId()] = $rule->getDiscountAmount();
|
199 |
+
}
|
200 |
+
if ($cartRules[$rule->getId()] > 0) {
|
201 |
+
$cartSponsorPoints = max($item->getCartFidelityPoints(), $cartRules[$rule->getId()]);
|
202 |
+
$cartRules[$rule->getId()] -= $cartSponsorPoints;
|
203 |
+
}
|
204 |
+
$address->setCartFixedRules($cartRules);
|
205 |
+
break;
|
206 |
+
//fin case perso-------------------------------------------------------------------
|
207 |
+
}
|
208 |
+
|
209 |
+
$result = new Varien_Object(array(
|
210 |
+
'discount_amount' => $discountAmount,
|
211 |
+
'base_discount_amount' => $baseDiscountAmount,
|
212 |
+
'cart_fidelity_points' => $cartFidelityPoints,
|
213 |
+
'cart_sponsor_points' => $cartSponsorPoints,
|
214 |
+
));
|
215 |
+
Mage::dispatchEvent('salesrule_validator_process', array(
|
216 |
+
'rule' => $rule,
|
217 |
+
'item' => $item,
|
218 |
+
'address' => $address,
|
219 |
+
'quote' => $quote,
|
220 |
+
'qty' => $qty,
|
221 |
+
'result' => $result,
|
222 |
+
));
|
223 |
+
|
224 |
+
$discountAmount = $quote->getStore()->roundPrice($discountAmount);
|
225 |
+
$baseDiscountAmount = $quote->getStore()->roundPrice($baseDiscountAmount);
|
226 |
+
$discountAmount = min($item->getDiscountAmount()+$discountAmount, $item->getRowTotal());
|
227 |
+
$baseDiscountAmount = min($item->getBaseDiscountAmount()+$baseDiscountAmount, $item->getBaseRowTotal());
|
228 |
+
|
229 |
+
//On garde uniquement la règle qui apporte leplus de points
|
230 |
+
$cartFidelityPoints = max($item->getCartFidelityPoints(), $cartFidelityPoints);
|
231 |
+
$cartSponsorPoints = max($item->getCartSponsorPoints(), $cartSponsorPoints);
|
232 |
+
|
233 |
+
$item->setDiscountAmount($discountAmount);
|
234 |
+
$item->setBaseDiscountAmount($baseDiscountAmount);
|
235 |
+
|
236 |
+
$item->setCartFidelityPoints($cartFidelityPoints);
|
237 |
+
$item->setCartSponsorPoints($cartSponsorPoints);
|
238 |
+
|
239 |
+
switch ($rule->getSimpleFreeShipping()) {
|
240 |
+
case Mage_SalesRule_Model_Rule::FREE_SHIPPING_ITEM:
|
241 |
+
$item->setFreeShipping($rule->getDiscountQty() ? $rule->getDiscountQty() : true);
|
242 |
+
break;
|
243 |
+
|
244 |
+
case Mage_SalesRule_Model_Rule::FREE_SHIPPING_ADDRESS:
|
245 |
+
$address->setFreeShipping(true);
|
246 |
+
break;
|
247 |
+
}
|
248 |
+
|
249 |
+
$appliedRuleIds[$rule->getRuleId()] = $rule->getRuleId();
|
250 |
+
|
251 |
+
if ($rule->getCouponCode() && ( strtolower($rule->getCouponCode()) == strtolower($this->getCouponCode()))) {
|
252 |
+
$address->setCouponCode($this->getCouponCode());
|
253 |
+
}
|
254 |
+
|
255 |
+
if ($rule->getStopRulesProcessing()) {
|
256 |
+
break;
|
257 |
+
}
|
258 |
+
}
|
259 |
+
|
260 |
+
$item->setAppliedRuleIds(join(',',$appliedRuleIds));
|
261 |
+
$address->setAppliedRuleIds($this->mergeIds($address->getAppliedRuleIds(), $appliedRuleIds));
|
262 |
+
$quote->setAppliedRuleIds($this->mergeIds($quote->getAppliedRuleIds(), $appliedRuleIds));
|
263 |
+
return $this;
|
264 |
+
}
|
265 |
+
}
|
266 |
+
?>
|
app/code/community/Auguria/Sponsorship/Model/Fidelitylog.php
ADDED
@@ -0,0 +1,15 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* @category Auguria
|
4 |
+
* @package Auguria_Sponsorship
|
5 |
+
* @author Auguria
|
6 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
7 |
+
*/
|
8 |
+
class Auguria_Sponsorship_Model_FidelityLog extends Mage_Core_Model_Abstract
|
9 |
+
{
|
10 |
+
public function _construct()
|
11 |
+
{
|
12 |
+
parent::_construct();
|
13 |
+
$this->_init('sponsorship/fidelitylog');
|
14 |
+
}
|
15 |
+
}
|
app/code/community/Auguria/Sponsorship/Model/Mysql4/CatalogFidelityPoint.php
ADDED
@@ -0,0 +1,15 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* @category Auguria
|
4 |
+
* @package Auguria_Sponsorship
|
5 |
+
* @author Auguria
|
6 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
7 |
+
*/
|
8 |
+
class Auguria_Sponsorship_Model_Mysql4_CatalogFidelityPoint extends Mage_Core_Model_Mysql4_Abstract
|
9 |
+
{
|
10 |
+
public function _construct()
|
11 |
+
{
|
12 |
+
// Note that the sponsorship_id refers to the key field in your database table.
|
13 |
+
$this->_init('sponsorship/catalogfidelitypoint', 'rule_product_fidelity_point_id');
|
14 |
+
}
|
15 |
+
}
|
app/code/community/Auguria/Sponsorship/Model/Mysql4/CatalogFidelityPoint/Collection.php
ADDED
@@ -0,0 +1,15 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* @category Auguria
|
4 |
+
* @package Auguria_Sponsorship
|
5 |
+
* @author Auguria
|
6 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
7 |
+
*/
|
8 |
+
class Auguria_Sponsorship_Model_Mysql4_CatalogFidelityPoint_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract
|
9 |
+
{
|
10 |
+
public function _construct()
|
11 |
+
{
|
12 |
+
parent::_construct();
|
13 |
+
$this->_init('sponsorship/catalogfidelitypoint');
|
14 |
+
}
|
15 |
+
}
|
app/code/community/Auguria/Sponsorship/Model/Mysql4/CatalogSponsorPoint.php
ADDED
@@ -0,0 +1,15 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* @category Auguria
|
4 |
+
* @package Auguria_Sponsorship
|
5 |
+
* @author Auguria
|
6 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
7 |
+
*/
|
8 |
+
class Auguria_Sponsorship_Model_Mysql4_CatalogSponsorPoint extends Mage_Core_Model_Mysql4_Abstract
|
9 |
+
{
|
10 |
+
public function _construct()
|
11 |
+
{
|
12 |
+
// Note that the sponsorship_id refers to the key field in your database table.
|
13 |
+
$this->_init('sponsorship/catalogsponsorpoint', 'rule_product_sponsor_point_id');
|
14 |
+
}
|
15 |
+
}
|
app/code/community/Auguria/Sponsorship/Model/Mysql4/CatalogSponsorPoint/Collection.php
ADDED
@@ -0,0 +1,15 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* @category Auguria
|
4 |
+
* @package Auguria_Sponsorship
|
5 |
+
* @author Auguria
|
6 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
7 |
+
*/
|
8 |
+
class Auguria_Sponsorship_Model_Mysql4_CatalogSponsorPoint_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract
|
9 |
+
{
|
10 |
+
public function _construct()
|
11 |
+
{
|
12 |
+
parent::_construct();
|
13 |
+
$this->_init('sponsorship/catalogsponsorpoint');
|
14 |
+
}
|
15 |
+
}
|
app/code/community/Auguria/Sponsorship/Model/Mysql4/Change.php
ADDED
@@ -0,0 +1,15 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* @category Auguria
|
4 |
+
* @package Auguria_Sponsorship
|
5 |
+
* @author Auguria
|
6 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
7 |
+
*/
|
8 |
+
class Auguria_Sponsorship_Model_Mysql4_Change extends Mage_Core_Model_Mysql4_Abstract
|
9 |
+
{
|
10 |
+
public function _construct()
|
11 |
+
{
|
12 |
+
// Note that the sponsorship_id refers to the key field in your database table.
|
13 |
+
$this->_init('sponsorship/change', 'sponsorship_change_id');
|
14 |
+
}
|
15 |
+
}
|
app/code/community/Auguria/Sponsorship/Model/Mysql4/Change/Collection.php
ADDED
@@ -0,0 +1,33 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* @category Auguria
|
4 |
+
* @package Auguria_Sponsorship
|
5 |
+
* @author Auguria
|
6 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
7 |
+
*/
|
8 |
+
class Auguria_Sponsorship_Model_Mysql4_Change_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract
|
9 |
+
{
|
10 |
+
public function _construct()
|
11 |
+
{
|
12 |
+
parent::_construct();
|
13 |
+
$this->_init('sponsorship/change');
|
14 |
+
}
|
15 |
+
|
16 |
+
public function addAttributeToFilter($nameField, $value)
|
17 |
+
{
|
18 |
+
$this->getSelect()
|
19 |
+
->where($nameField.' = ?', $value);
|
20 |
+
return $this;
|
21 |
+
}
|
22 |
+
|
23 |
+
public function addNameToSelect()
|
24 |
+
{
|
25 |
+
$customer = Mage::getModel('customer/customer');
|
26 |
+
$firstname = $customer->getAttribute('firstname');
|
27 |
+
$lastname = $customer->getAttribute('lastname');
|
28 |
+
$core = Mage::getSingleton('core/resource');
|
29 |
+
$this->getSelect()
|
30 |
+
->from(null, array("customer_name"=>new Zend_Db_Expr('CONCAT((select cev.value from '.$core->getTableName('customer_entity_varchar').' cev where cev.entity_id=customer_id and cev.attribute_id='.(int) $firstname->getAttributeId().')," ",(select cev.value from '.$core->getTableName('customer_entity_varchar').' cev where cev.entity_id=customer_id and cev.attribute_id='.(int) $lastname->getAttributeId().'))')));
|
31 |
+
return $this;
|
32 |
+
}
|
33 |
+
}
|
app/code/community/Auguria/Sponsorship/Model/Mysql4/FidelityLog/Collection.php
ADDED
@@ -0,0 +1,15 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* @category Auguria
|
4 |
+
* @package Auguria_Sponsorship
|
5 |
+
* @author Auguria
|
6 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
7 |
+
*/
|
8 |
+
class Auguria_Sponsorship_Model_Mysql4_FidelityLog_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract
|
9 |
+
{
|
10 |
+
public function _construct()
|
11 |
+
{
|
12 |
+
parent::_construct();
|
13 |
+
$this->_init('sponsorship/fidelitylog');
|
14 |
+
}
|
15 |
+
}
|
app/code/community/Auguria/Sponsorship/Model/Mysql4/Fidelitylog.php
ADDED
@@ -0,0 +1,15 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* @category Auguria
|
4 |
+
* @package Auguria_Sponsorship
|
5 |
+
* @author Auguria
|
6 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
7 |
+
*/
|
8 |
+
class Auguria_Sponsorship_Model_Mysql4_FidelityLog extends Mage_Core_Model_Mysql4_Abstract
|
9 |
+
{
|
10 |
+
public function _construct()
|
11 |
+
{
|
12 |
+
// Note that the sponsorship_id refers to the key field in your database table.
|
13 |
+
$this->_init('sponsorship/fidelitylog', 'sponsorship_fidelity_log_id');
|
14 |
+
}
|
15 |
+
}
|
app/code/community/Auguria/Sponsorship/Model/Mysql4/Rule.php
ADDED
@@ -0,0 +1,394 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* @category Auguria
|
4 |
+
* @package Auguria_Sponsorship
|
5 |
+
* @author Auguria
|
6 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
7 |
+
*/
|
8 |
+
class Auguria_Sponsorship_Model_Mysql4_Rule extends Mage_CatalogRule_Model_Mysql4_Rule
|
9 |
+
{
|
10 |
+
protected function _construct()
|
11 |
+
{
|
12 |
+
parent::_construct();
|
13 |
+
}
|
14 |
+
|
15 |
+
public function applyAllRulesForDateRange($fromDate=null, $toDate=null, $productId=null)
|
16 |
+
{
|
17 |
+
$write = $this->_getWriteAdapter();
|
18 |
+
$write->beginTransaction();
|
19 |
+
|
20 |
+
Mage::dispatchEvent('catalogrule_before_apply', array('resource'=>$this));
|
21 |
+
|
22 |
+
$clearOldData = false;
|
23 |
+
if ($fromDate === null) {
|
24 |
+
$fromDate = mktime(0,0,0,date('m'),date('d')-1);
|
25 |
+
/**
|
26 |
+
* If fromDate not specified we can delete all data oldest than 1 day
|
27 |
+
* We have run it for clear table in case when cron was not installed
|
28 |
+
* and old data exist in table
|
29 |
+
*/
|
30 |
+
$clearOldData = true;
|
31 |
+
}
|
32 |
+
if (is_string($fromDate)) {
|
33 |
+
$fromDate = strtotime($fromDate);
|
34 |
+
}
|
35 |
+
if ($toDate === null) {
|
36 |
+
$toDate = mktime(0,0,0,date('m'),date('d')+1);
|
37 |
+
}
|
38 |
+
if (is_string($toDate)) {
|
39 |
+
$toDate = strtotime($toDate);
|
40 |
+
}
|
41 |
+
|
42 |
+
$product = null;
|
43 |
+
if ($productId instanceof Mage_Catalog_Model_Product) {
|
44 |
+
$product = $productId;
|
45 |
+
$productId = $productId->getId();
|
46 |
+
}
|
47 |
+
|
48 |
+
$this->removeCatalogPricesForDateRange($fromDate, $toDate, $productId);
|
49 |
+
if ($clearOldData) {
|
50 |
+
$this->deleteOldData($fromDate, $productId);
|
51 |
+
}
|
52 |
+
|
53 |
+
try {
|
54 |
+
/**
|
55 |
+
* Update products rules prices per each website separatly
|
56 |
+
* because of max join limit in mysql
|
57 |
+
*/
|
58 |
+
foreach (Mage::app()->getWebsites(false) as $website) {
|
59 |
+
$productsStmt = $this->_getRuleProductsStmt(
|
60 |
+
$fromDate,
|
61 |
+
$toDate,
|
62 |
+
$productId,
|
63 |
+
$website->getId()
|
64 |
+
);
|
65 |
+
|
66 |
+
$dayPrices = array();
|
67 |
+
$dayFidelityPoints = array();
|
68 |
+
$daySponsorPoints = array();
|
69 |
+
$stopFlags = array();
|
70 |
+
$prevKey = null;
|
71 |
+
|
72 |
+
while ($ruleData = $productsStmt->fetch()) {
|
73 |
+
|
74 |
+
$ruleActionOperator = $ruleData['action_operator'];
|
75 |
+
|
76 |
+
$ruleProductId = $ruleData['product_id'];
|
77 |
+
$productKey= $ruleProductId . '_'
|
78 |
+
. $ruleData['website_id'] . '_'
|
79 |
+
. $ruleData['customer_group_id'];
|
80 |
+
|
81 |
+
if ($prevKey && ($prevKey != $productKey)) {
|
82 |
+
$stopFlags = array();
|
83 |
+
}
|
84 |
+
|
85 |
+
/**
|
86 |
+
* Build prices for each day
|
87 |
+
*/
|
88 |
+
//si c'est une règle de prix
|
89 |
+
if ($ruleActionOperator == 'to_fixed' ||
|
90 |
+
$ruleActionOperator == 'to_percent' ||
|
91 |
+
$ruleActionOperator == 'by_fixed' ||
|
92 |
+
$ruleActionOperator == 'by_percent')
|
93 |
+
{
|
94 |
+
for ($time=$fromDate; $time<=$toDate; $time+=self::SECONDS_IN_DAY) {
|
95 |
+
if (($ruleData['from_time']==0 || $time >= $ruleData['from_time'])
|
96 |
+
&& ($ruleData['to_time']==0 || $time <=$ruleData['to_time'])) {
|
97 |
+
|
98 |
+
$priceKey = $time . '_' . $productKey;
|
99 |
+
|
100 |
+
if (isset($stopFlags[$priceKey])) {
|
101 |
+
continue;
|
102 |
+
}
|
103 |
+
|
104 |
+
if (!isset($dayPrices[$priceKey])) {
|
105 |
+
$dayPrices[$priceKey] = array(
|
106 |
+
'rule_date' => $time,
|
107 |
+
'website_id' => $ruleData['website_id'],
|
108 |
+
'customer_group_id' => $ruleData['customer_group_id'],
|
109 |
+
'product_id' => $ruleProductId,
|
110 |
+
'rule_price' => $this->_calcRuleProductPrice($ruleData),
|
111 |
+
'latest_start_date' => $ruleData['from_time'],
|
112 |
+
'earliest_end_date' => $ruleData['to_time'],
|
113 |
+
);
|
114 |
+
}
|
115 |
+
else {
|
116 |
+
$dayPrices[$priceKey]['rule_price'] = $this->_calcRuleProductPrice(
|
117 |
+
$ruleData,
|
118 |
+
$dayPrices[$priceKey]
|
119 |
+
);
|
120 |
+
$dayPrices[$priceKey]['latest_start_date'] = max(
|
121 |
+
$dayPrices[$priceKey]['latest_start_date'],
|
122 |
+
$ruleData['from_time']
|
123 |
+
);
|
124 |
+
$dayPrices[$priceKey]['earliest_end_date'] = min(
|
125 |
+
$dayPrices[$priceKey]['earliest_end_date'],
|
126 |
+
$ruleData['to_time']
|
127 |
+
);
|
128 |
+
}
|
129 |
+
|
130 |
+
if ($ruleData['action_stop']) {
|
131 |
+
$stopFlags[$priceKey] = true;
|
132 |
+
}
|
133 |
+
}
|
134 |
+
}
|
135 |
+
}
|
136 |
+
//si c'est une règle de points fidélité
|
137 |
+
elseif ($ruleActionOperator == 'fidelity_points_to_percent' ||
|
138 |
+
$ruleActionOperator == 'fidelity_points_to_fixed')
|
139 |
+
{
|
140 |
+
for ($time=$fromDate; $time<=$toDate; $time+=self::SECONDS_IN_DAY) {
|
141 |
+
if (($ruleData['from_time']==0 || $time >= $ruleData['from_time'])
|
142 |
+
&& ($ruleData['to_time']==0 || $time <=$ruleData['to_time'])) {
|
143 |
+
|
144 |
+
$priceKey = $time . '_' . $productKey;
|
145 |
+
|
146 |
+
if (isset($stopFlags[$priceKey])) {
|
147 |
+
continue;
|
148 |
+
}
|
149 |
+
|
150 |
+
if (!isset($dayFidelityPoints[$priceKey])) {
|
151 |
+
$dayFidelityPoints[$priceKey] = array(
|
152 |
+
'rule_date' => $time,
|
153 |
+
'website_id' => $ruleData['website_id'],
|
154 |
+
'customer_group_id' => $ruleData['customer_group_id'],
|
155 |
+
'product_id' => $ruleProductId,
|
156 |
+
'rule_price' => $this->_calcRuleProductPrice($ruleData),
|
157 |
+
'latest_start_date' => $ruleData['from_time'],
|
158 |
+
'earliest_end_date' => $ruleData['to_time'],
|
159 |
+
);
|
160 |
+
}
|
161 |
+
else {
|
162 |
+
$dayFidelityPoints[$priceKey]['rule_price'] = $this->_calcRuleProductPrice(
|
163 |
+
$ruleData,
|
164 |
+
$dayFidelityPoints[$priceKey]
|
165 |
+
);
|
166 |
+
$dayFidelityPoints[$priceKey]['latest_start_date'] = max(
|
167 |
+
$dayFidelityPoints[$priceKey]['latest_start_date'],
|
168 |
+
$ruleData['from_time']
|
169 |
+
);
|
170 |
+
$dayFidelityPoints[$priceKey]['earliest_end_date'] = min(
|
171 |
+
$dayFidelityPoints[$priceKey]['earliest_end_date'],
|
172 |
+
$ruleData['to_time']
|
173 |
+
);
|
174 |
+
}
|
175 |
+
|
176 |
+
if ($ruleData['action_stop']) {
|
177 |
+
$stopFlags[$priceKey] = true;
|
178 |
+
}
|
179 |
+
}
|
180 |
+
}
|
181 |
+
}
|
182 |
+
else if ($ruleActionOperator == 'sponsor_points_to_percent' ||
|
183 |
+
$ruleActionOperator == 'sponsor_points_to_fixed')
|
184 |
+
{
|
185 |
+
for ($time=$fromDate; $time<=$toDate; $time+=self::SECONDS_IN_DAY) {
|
186 |
+
if (($ruleData['from_time']==0 || $time >= $ruleData['from_time'])
|
187 |
+
&& ($ruleData['to_time']==0 || $time <=$ruleData['to_time'])) {
|
188 |
+
|
189 |
+
$priceKey = $time . '_' . $productKey;
|
190 |
+
|
191 |
+
if (isset($stopFlags[$priceKey])) {
|
192 |
+
continue;
|
193 |
+
}
|
194 |
+
|
195 |
+
if (!isset($daySponsorPoints[$priceKey])) {
|
196 |
+
$daySponsorPoints[$priceKey] = array(
|
197 |
+
'rule_date' => $time,
|
198 |
+
'website_id' => $ruleData['website_id'],
|
199 |
+
'customer_group_id' => $ruleData['customer_group_id'],
|
200 |
+
'product_id' => $ruleProductId,
|
201 |
+
'rule_price' => $this->_calcRuleProductPrice($ruleData),
|
202 |
+
'latest_start_date' => $ruleData['from_time'],
|
203 |
+
'earliest_end_date' => $ruleData['to_time'],
|
204 |
+
);
|
205 |
+
}
|
206 |
+
else {
|
207 |
+
$daySponsorPoints[$priceKey]['rule_price'] = $this->_calcRuleProductPrice(
|
208 |
+
$ruleData,
|
209 |
+
$daySponsorPoints[$priceKey]
|
210 |
+
);
|
211 |
+
$daySponsorPoints[$priceKey]['latest_start_date'] = max(
|
212 |
+
$daySponsorPoints[$priceKey]['latest_start_date'],
|
213 |
+
$ruleData['from_time']
|
214 |
+
);
|
215 |
+
$daySponsorPoints[$priceKey]['earliest_end_date'] = min(
|
216 |
+
$daySponsorPoints[$priceKey]['earliest_end_date'],
|
217 |
+
$ruleData['to_time']
|
218 |
+
);
|
219 |
+
}
|
220 |
+
|
221 |
+
if ($ruleData['action_stop']) {
|
222 |
+
$stopFlags[$priceKey] = true;
|
223 |
+
}
|
224 |
+
}
|
225 |
+
}
|
226 |
+
}//fin elsif
|
227 |
+
|
228 |
+
$prevKey = $productKey;
|
229 |
+
|
230 |
+
if ((count($dayPrices)+count($dayFidelityPoints)+count($daySponsorPoints))>100) {
|
231 |
+
$this->_saveRuleProductPrices($dayPrices);
|
232 |
+
$this->_saveRuleProductPoints($dayFidelityPoints,'fidelity');
|
233 |
+
$this->_saveRuleProductPoints($daySponsorPoints,'sponsor');
|
234 |
+
$dayPrices = array();
|
235 |
+
$dayFidelityPoints = array();
|
236 |
+
$daySponsorPoints = array();
|
237 |
+
}
|
238 |
+
}
|
239 |
+
$this->_saveRuleProductPrices($dayPrices);
|
240 |
+
$this->_saveRuleProductPoints($dayFidelityPoints,'fidelity');
|
241 |
+
$this->_saveRuleProductPoints($daySponsorPoints,'sponsor');
|
242 |
+
}
|
243 |
+
$this->_saveRuleProductPrices($dayPrices);
|
244 |
+
$this->_saveRuleProductPoints($dayFidelityPoints,'fidelity');
|
245 |
+
$this->_saveRuleProductPoints($daySponsorPoints,'sponsor');
|
246 |
+
$write->commit();
|
247 |
+
|
248 |
+
} catch (Exception $e) {
|
249 |
+
$write->rollback();
|
250 |
+
throw $e;
|
251 |
+
}
|
252 |
+
|
253 |
+
$productCondition = Mage::getModel('catalog/product_condition')
|
254 |
+
->setTable($this->getTable('catalogrule/affected_product'))
|
255 |
+
->setPkFieldName('product_id');
|
256 |
+
Mage::dispatchEvent('catalogrule_after_apply', array(
|
257 |
+
'product'=>$product,
|
258 |
+
'product_condition' => $productCondition
|
259 |
+
));
|
260 |
+
$write->delete($this->getTable('catalogrule/affected_product'));
|
261 |
+
|
262 |
+
return $this;
|
263 |
+
}
|
264 |
+
|
265 |
+
protected function _calcRuleProductPrice($ruleData, $productData=null)
|
266 |
+
{
|
267 |
+
if ($productData !== null && isset($productData['rule_price'])) {
|
268 |
+
$productPrice = $productData['rule_price'];
|
269 |
+
}
|
270 |
+
else {
|
271 |
+
$websiteId = $ruleData['website_id'];
|
272 |
+
if (isset($ruleData['website_'.$websiteId.'_price'])) {
|
273 |
+
$productPrice = $ruleData['website_'.$websiteId.'_price'];
|
274 |
+
}
|
275 |
+
else {
|
276 |
+
$productPrice = $ruleData['default_price'];
|
277 |
+
}
|
278 |
+
}
|
279 |
+
|
280 |
+
$amount = $ruleData['action_amount'];
|
281 |
+
switch ($ruleData['action_operator']) {
|
282 |
+
case 'to_fixed':
|
283 |
+
$productPrice = $amount;
|
284 |
+
break;
|
285 |
+
case 'fidelity_points_to_fixed':
|
286 |
+
$productPrice = $amount;
|
287 |
+
break;
|
288 |
+
case 'sponsor_points_to_fixed':
|
289 |
+
$productPrice = $amount;
|
290 |
+
break;
|
291 |
+
case 'to_percent':
|
292 |
+
$productPrice= $productPrice*$amount/100;
|
293 |
+
break;
|
294 |
+
case 'fidelity_points_to_percent':
|
295 |
+
$productPrice= $productPrice*$amount/100;
|
296 |
+
break;
|
297 |
+
case 'sponsor_points_to_percent':
|
298 |
+
$productPrice= $productPrice*$amount/100;
|
299 |
+
break;
|
300 |
+
case 'by_fixed':
|
301 |
+
$productPrice -= $amount;
|
302 |
+
break;
|
303 |
+
case 'by_percent':
|
304 |
+
$productPrice = $productPrice*(1-$amount/100);
|
305 |
+
break;
|
306 |
+
}
|
307 |
+
|
308 |
+
$productPrice = max($productPrice, 0);
|
309 |
+
return Mage::app()->getStore()->roundPrice($productPrice);
|
310 |
+
}
|
311 |
+
|
312 |
+
protected function _saveRuleProductPoints($arrData,$type)
|
313 |
+
{
|
314 |
+
if (empty($arrData)) {
|
315 |
+
return $this;
|
316 |
+
}
|
317 |
+
$header = 'replace into '.$this->getTable('sponsorship/catalog'.$type.'point').' (
|
318 |
+
rule_date,
|
319 |
+
website_id,
|
320 |
+
customer_group_id,
|
321 |
+
product_id,
|
322 |
+
rule_point,
|
323 |
+
latest_start_date,
|
324 |
+
earliest_end_date
|
325 |
+
) values ';
|
326 |
+
$rows = array();
|
327 |
+
$productIds = array();
|
328 |
+
foreach ($arrData as $data) {
|
329 |
+
$productIds[$data['product_id']] = true;
|
330 |
+
$data['rule_date'] = $this->formatDate($data['rule_date'], false);
|
331 |
+
$data['latest_start_date'] = $this->formatDate($data['latest_start_date'], false);
|
332 |
+
$data['earliest_end_date'] = $this->formatDate($data['earliest_end_date'], false);
|
333 |
+
$rows[] = '(' . $this->_getWriteAdapter()->quote($data) . ')';
|
334 |
+
}
|
335 |
+
$query = $header.join(',', $rows);
|
336 |
+
$insertQuery = 'REPLACE INTO ' . $this->getTable('catalogrule/affected_product') . ' (product_id) VALUES ' .
|
337 |
+
'(' . join('),(', array_keys($productIds)) . ')';
|
338 |
+
$this->_getWriteAdapter()->query($insertQuery);
|
339 |
+
$this->_getWriteAdapter()->query($query);
|
340 |
+
return $this;
|
341 |
+
}
|
342 |
+
|
343 |
+
public function removeCatalogPricesForDateRange($fromDate, $toDate, $productId=null)
|
344 |
+
{
|
345 |
+
$write = $this->_getWriteAdapter();
|
346 |
+
$conds = array();
|
347 |
+
$cond = $write->quoteInto('rule_date between ?', $this->formatDate($fromDate));
|
348 |
+
$cond = $write->quoteInto($cond.' and ?', $this->formatDate($toDate));
|
349 |
+
$conds[] = $cond;
|
350 |
+
if (!is_null($productId)) {
|
351 |
+
$conds[] = $write->quoteInto('product_id=?', $productId);
|
352 |
+
}
|
353 |
+
|
354 |
+
/**
|
355 |
+
* Add information about affected products
|
356 |
+
* It can be used in processes which related with product price (like catalog index)
|
357 |
+
*/
|
358 |
+
$select = $this->_getWriteAdapter()->select()
|
359 |
+
->from($this->getTable('catalogrule/rule_product_price'), 'product_id')
|
360 |
+
->where(implode(' AND ', $conds));
|
361 |
+
$insertQuery = 'REPLACE INTO ' . $this->getTable('catalogrule/affected_product') . ' (product_id)' . $select->__toString();
|
362 |
+
$this->_getWriteAdapter()->query($insertQuery);
|
363 |
+
$write->delete($this->getTable('catalogrule/rule_product_price'), $conds);
|
364 |
+
|
365 |
+
$selectFidelityPoint = $this->_getWriteAdapter()->select()
|
366 |
+
->from($this->getTable('sponsorship/catalogfidelitypoint'), 'product_id')
|
367 |
+
->where(implode(' AND ', $conds));
|
368 |
+
$insertQuery = 'REPLACE INTO ' . $this->getTable('catalogrule/affected_product') . ' (product_id)' .$selectFidelityPoint->__toString();
|
369 |
+
$this->_getWriteAdapter()->query($insertQuery);
|
370 |
+
$write->delete($this->getTable('sponsorship/catalogfidelitypoint'), $conds);
|
371 |
+
|
372 |
+
$selectSponsorPoint = $this->_getWriteAdapter()->select()
|
373 |
+
->from($this->getTable('sponsorship/catalogsponsorpoint'), 'product_id')
|
374 |
+
->where(implode(' AND ', $conds));
|
375 |
+
$insertQuery = 'REPLACE INTO ' . $this->getTable('catalogrule/affected_product') . ' (product_id)' .$selectSponsorPoint->__toString();
|
376 |
+
$this->_getWriteAdapter()->query($insertQuery);
|
377 |
+
$write->delete($this->getTable('sponsorship/catalogsponsorpoint'), $conds);
|
378 |
+
|
379 |
+
return $this;
|
380 |
+
}
|
381 |
+
|
382 |
+
public function deleteOldData($date, $productId=null)
|
383 |
+
{
|
384 |
+
$write = $this->_getWriteAdapter();
|
385 |
+
$conds = array();
|
386 |
+
$conds[] = $write->quoteInto('rule_date<?', $this->formatDate($date));
|
387 |
+
if (!is_null($productId)) {
|
388 |
+
$conds[] = $write->quoteInto('product_id=?', $productId);
|
389 |
+
}
|
390 |
+
$write->delete($this->getTable('catalogrule/rule_product_price'), $conds);
|
391 |
+
$write->delete($this->getTable('sponsorship/catalogfidelitypoint'), $conds);
|
392 |
+
return $this;
|
393 |
+
}
|
394 |
+
}
|
app/code/community/Auguria/Sponsorship/Model/Mysql4/Sponsorlog.php
ADDED
@@ -0,0 +1,15 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* @category Auguria
|
4 |
+
* @package Auguria_Sponsorship
|
5 |
+
* @author Auguria
|
6 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
7 |
+
*/
|
8 |
+
class Auguria_Sponsorship_Model_Mysql4_SponsorLog extends Mage_Core_Model_Mysql4_Abstract
|
9 |
+
{
|
10 |
+
public function _construct()
|
11 |
+
{
|
12 |
+
// Note that the sponsorship_id refers to the key field in your database table.
|
13 |
+
$this->_init('sponsorship/sponsorlog', 'sponsorship_sponsor_log_id');
|
14 |
+
}
|
15 |
+
}
|
app/code/community/Auguria/Sponsorship/Model/Mysql4/Sponsorlog/Collection.php
ADDED
@@ -0,0 +1,15 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* @category Auguria
|
4 |
+
* @package Auguria_Sponsorship
|
5 |
+
* @author Auguria
|
6 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
7 |
+
*/
|
8 |
+
class Auguria_Sponsorship_Model_Mysql4_SponsorLog_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract
|
9 |
+
{
|
10 |
+
public function _construct()
|
11 |
+
{
|
12 |
+
parent::_construct();
|
13 |
+
$this->_init('sponsorship/sponsorlog');
|
14 |
+
}
|
15 |
+
}
|
app/code/community/Auguria/Sponsorship/Model/Mysql4/Sponsorship.php
ADDED
@@ -0,0 +1,15 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* @category Auguria
|
4 |
+
* @package Auguria_Sponsorship
|
5 |
+
* @author Auguria
|
6 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
7 |
+
*/
|
8 |
+
class Auguria_Sponsorship_Model_Mysql4_Sponsorship extends Mage_Core_Model_Mysql4_Abstract
|
9 |
+
{
|
10 |
+
public function _construct()
|
11 |
+
{
|
12 |
+
// Note that the sponsorship_id refers to the key field in your database table.
|
13 |
+
$this->_init('sponsorship/sponsorship', 'sponsorship_id');
|
14 |
+
}
|
15 |
+
}
|
app/code/community/Auguria/Sponsorship/Model/Mysql4/Sponsorship/Collection.php
ADDED
@@ -0,0 +1,36 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* @category Auguria
|
4 |
+
* @package Auguria_Sponsorship
|
5 |
+
* @author Auguria
|
6 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
7 |
+
*/
|
8 |
+
class Auguria_Sponsorship_Model_Mysql4_Sponsorship_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract
|
9 |
+
{
|
10 |
+
public function _construct()
|
11 |
+
{
|
12 |
+
parent::_construct();
|
13 |
+
$this->_init('sponsorship/sponsorship');
|
14 |
+
}
|
15 |
+
|
16 |
+
public function addAttributeToFilter($nameField, $value)
|
17 |
+
{
|
18 |
+
$this->getSelect()
|
19 |
+
->where($nameField.' = ?', $value);
|
20 |
+
return $this;
|
21 |
+
}
|
22 |
+
|
23 |
+
public function addDateToFilter($nameField, $value)
|
24 |
+
{
|
25 |
+
$this->getSelect()
|
26 |
+
->where('TO_DAYS(NOW()) - TO_DAYS('.$nameField.') <= ?', $value);
|
27 |
+
return $this;
|
28 |
+
}
|
29 |
+
|
30 |
+
public function addChildNameToSelect()
|
31 |
+
{
|
32 |
+
$this->getSelect()
|
33 |
+
->from(null, array("child_name"=>new Zend_Db_Expr('CONCAT(child_firstname," ",child_lastname)')));
|
34 |
+
return $this;
|
35 |
+
}
|
36 |
+
}
|
app/code/community/Auguria/Sponsorship/Model/Observer.php
ADDED
@@ -0,0 +1,334 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* @category Auguria
|
4 |
+
* @package Auguria_Sponsorship
|
5 |
+
* @author Auguria
|
6 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
7 |
+
*/
|
8 |
+
class Auguria_Sponsorship_Model_Observer
|
9 |
+
{
|
10 |
+
public function calcPoints($observer)
|
11 |
+
{
|
12 |
+
try {
|
13 |
+
mage::log("début debug-----------------------------------------------------------------------");
|
14 |
+
//récupération de la commande et des articles
|
15 |
+
$order = $observer->getInvoice()->getOrder();
|
16 |
+
$orderDate = $order->getUpdatedAt();
|
17 |
+
$orderId = $order->getEntityId();
|
18 |
+
|
19 |
+
//définition du client
|
20 |
+
$cId = $order->getCustomerId();
|
21 |
+
|
22 |
+
//definition du websiteid
|
23 |
+
$wId = $order->getStore()->getWebsiteId();
|
24 |
+
|
25 |
+
//definition du groupe du client
|
26 |
+
$gId = Mage::getModel('customer/customer')->load($cId)->getGroupId();
|
27 |
+
|
28 |
+
mage::log($orderId." ".$cId);
|
29 |
+
//definition du sponsor de premier niveau
|
30 |
+
$sponsorId = $this->getSponsorId($cId);
|
31 |
+
$sponsor = Mage::getModel('customer/customer')->load($sponsorId);
|
32 |
+
$special_rate = $sponsor->getData('special_rate');
|
33 |
+
//variable de points
|
34 |
+
$tCatalogFidelityPoints=0;
|
35 |
+
$tCatalogSponsorPoints=0;
|
36 |
+
$tCartFidelityPoints=0;
|
37 |
+
$tCartSponsorPoints=0;
|
38 |
+
|
39 |
+
|
40 |
+
//modules actifs
|
41 |
+
$moduleFidelity = Mage::getStoreConfig('sponsorship/fidelity/fidelity_enabled');
|
42 |
+
$moduleSponsor = Mage::getStoreConfig('sponsorship/sponsor/sponsor_enabled');
|
43 |
+
|
44 |
+
//calcul des points catalogue et mise à jour de lacommande pour chaque ligne
|
45 |
+
foreach ($order->getAllItems() as $item)
|
46 |
+
{
|
47 |
+
$date = $item->getData('updated_at');
|
48 |
+
$pId = $item->getData('product_id');
|
49 |
+
$qte = $item->getData('qty_ordered');
|
50 |
+
$data = $item->getData();
|
51 |
+
|
52 |
+
if ($moduleFidelity)
|
53 |
+
{
|
54 |
+
mage::log("module fidélité ok");
|
55 |
+
if ($item->getData('price') > 0) //vérification pour bundle : ne pas ajouter des points si le prix de l'article est 0 : idéalement, il faudrait revoir les règles de prix pour les articles packagés
|
56 |
+
{
|
57 |
+
//récupération et affectation des points catalog pour chaque article commandé
|
58 |
+
$catalogFidelityPoints = $this->getRulePoints($date, $wId, $gId, $pId,'fidelity');
|
59 |
+
//multiplication des points par la quantité
|
60 |
+
$catalogFidelityPoints = $catalogFidelityPoints*$qte;
|
61 |
+
|
62 |
+
//ajout des points aux items de commande
|
63 |
+
$data['catalog_fidelity_points'] = $catalogFidelityPoints;
|
64 |
+
|
65 |
+
//calcul du total de points catalogue
|
66 |
+
$tCatalogFidelityPoints = $tCatalogFidelityPoints+$catalogFidelityPoints;
|
67 |
+
}
|
68 |
+
|
69 |
+
//calcul du total de points panier
|
70 |
+
$tCartFidelityPoints = $tCartFidelityPoints+$item->getCartFidelityPoints();
|
71 |
+
}
|
72 |
+
|
73 |
+
if ($moduleSponsor && $special_rate==null)
|
74 |
+
{
|
75 |
+
mage::log("module parrainage ok sans taux spé");
|
76 |
+
if ($item->getData('price') > 0) //vérification pour bundle : ne pas ajouter des points si le prix de l'article est 0 : idéalement, il faudrait revoir les règles de prix pour les articles packagés
|
77 |
+
{
|
78 |
+
//récupération et affectation des points catalog pour chaque article commandé
|
79 |
+
$catalogSponsorPoints = $this->getRulePoints($date, $wId, $gId, $pId, 'sponsor');
|
80 |
+
|
81 |
+
//multiplication des points par la quantité
|
82 |
+
$catalogSponsorPoints = $catalogSponsorPoints*$qte;
|
83 |
+
|
84 |
+
//ajout des points aux items de commande
|
85 |
+
$data['catalog_sponsor_points'] = $catalogSponsorPoints;
|
86 |
+
//calcul du total de points catalogue
|
87 |
+
$tCatalogSponsorPoints = $tCatalogSponsorPoints+$catalogSponsorPoints;
|
88 |
+
}
|
89 |
+
|
90 |
+
//calcul du total de points panier
|
91 |
+
$tCartSponsorPoints = $tCartSponsorPoints+$item->getCartSponsorPoints();
|
92 |
+
}
|
93 |
+
//si un taux spécial est défini pour le parrain direct
|
94 |
+
elseif ($moduleSponsor && $special_rate!=null)
|
95 |
+
{
|
96 |
+
mage::log("module parrainage ok avec taux spé");
|
97 |
+
//Redéfinition du taux à appliquer dans la commande
|
98 |
+
if ($item->getData('price') > 0) //vérification pour bundle : ne pas ajouter des points si le prix de l'article est 0 : idéalement, il faudrait revoir les règles de prix pour les articles packagés
|
99 |
+
{
|
100 |
+
//ajout des points aux items de commande
|
101 |
+
$data['catalog_sponsor_points'] = 0;
|
102 |
+
$specialratepoints = $item->getData('price')*$qte*$special_rate/100;
|
103 |
+
$data['cart_sponsor_points'] = $specialratepoints;
|
104 |
+
}
|
105 |
+
|
106 |
+
}
|
107 |
+
|
108 |
+
if ($moduleFidelity||$moduleSponsor)
|
109 |
+
{
|
110 |
+
$item->setData($data);
|
111 |
+
$item->save();
|
112 |
+
}
|
113 |
+
}
|
114 |
+
|
115 |
+
$order->save();
|
116 |
+
|
117 |
+
//Ajout du total des points fidelite
|
118 |
+
if ($tCatalogFidelityPoints != 0 || $tCartFidelityPoints != 0 ) {
|
119 |
+
$this->addFidelityPoints($cId,$tCatalogFidelityPoints+$tCartFidelityPoints,$orderDate,$orderId);
|
120 |
+
}
|
121 |
+
|
122 |
+
//Ajout du total des points de parrainage si le parrain n'a pas de taux spécial
|
123 |
+
if (($tCatalogSponsorPoints != 0 || $tCartSponsorPoints != 0) && $special_rate==null) {
|
124 |
+
$this->addSponsorsPoints($cId,$tCatalogSponsorPoints+$tCartSponsorPoints,$orderDate,$orderId);
|
125 |
+
}
|
126 |
+
//Ajout des points à partir du taxu spécial au parrain direct uniquement
|
127 |
+
elseif ($special_rate!=null && $moduleSponsor) {
|
128 |
+
$this->addSponsorSpecialPoints($cId,$orderDate,$orderId,$order->subtotal, $special_rate);
|
129 |
+
}
|
130 |
+
|
131 |
+
|
132 |
+
mage::log("fin debug-----------------------------------------------------------------------");
|
133 |
+
return $this;
|
134 |
+
}
|
135 |
+
catch (Exception $e) {
|
136 |
+
Mage::log("An error occured while saving points :".$e->getMessage());
|
137 |
+
}
|
138 |
+
}
|
139 |
+
|
140 |
+
public function getRulePoints($date, $wId, $gId, $pId, $type)
|
141 |
+
{
|
142 |
+
$resource = Mage::getSingleton('core/resource');
|
143 |
+
$read= $resource->getConnection('core_read');
|
144 |
+
$userTable = $resource->getTableName('sponsorship/catalog'.$type.'point');
|
145 |
+
$select = $read->select()
|
146 |
+
->from($resource->getTableName('sponsorship/catalog'.$type.'point'), 'rule_point')
|
147 |
+
->where('rule_date=?', $this->formatDate($date))
|
148 |
+
->where('website_id=?', $wId)
|
149 |
+
->where('customer_group_id=?', $gId)
|
150 |
+
->where('product_id=?', $pId);
|
151 |
+
return $read->fetchOne($select);
|
152 |
+
}
|
153 |
+
|
154 |
+
public function formatDate ($date)
|
155 |
+
{
|
156 |
+
$date = strtotime($date);
|
157 |
+
return date('Y-m-d', $date);
|
158 |
+
}
|
159 |
+
|
160 |
+
public function addFidelityPoints($cId,$tFPoints,$orderDate,$orderId)
|
161 |
+
{
|
162 |
+
//récupération des points fidélité existants
|
163 |
+
$customer = Mage::getModel('customer/customer')->load($cId);
|
164 |
+
$iFPoints = $customer->getData('fidelity_points');
|
165 |
+
|
166 |
+
//ajout des points fidélité
|
167 |
+
$customer->setFidelityPoints($tFPoints+$iFPoints);
|
168 |
+
$customer->save();
|
169 |
+
|
170 |
+
//enregistrement dans les logs
|
171 |
+
$log = Mage::getModel('sponsorship/fidelitylog');
|
172 |
+
$data = array(
|
173 |
+
'customer_id' => $cId,
|
174 |
+
'record_id' => $orderId,
|
175 |
+
'record_type' => 'order',
|
176 |
+
'datetime' => $orderDate,
|
177 |
+
'points' => $tFPoints
|
178 |
+
);
|
179 |
+
$log->setData($data);
|
180 |
+
$log->save();
|
181 |
+
}
|
182 |
+
|
183 |
+
/*
|
184 |
+
* Add sponsor points to sponsors
|
185 |
+
*/
|
186 |
+
public function addSponsorsPoints($cId,$SPoints,$orderDate,$orderId)
|
187 |
+
{
|
188 |
+
$ratio = Mage::getStoreConfig('sponsorship/sponsor/sponsor_percent');
|
189 |
+
$maxLevel = Mage::getStoreConfig('sponsorship/sponsor/sponsor_levels');
|
190 |
+
$sponsorId = $this->getSponsorId($cId);
|
191 |
+
$godsonId = $cId;
|
192 |
+
|
193 |
+
//Ajout des points tant que le niveau maximum n'est pas atteint et qu'un parrain est défini
|
194 |
+
for ($level = 0; $level<$maxLevel AND $sponsorId!=null AND round($SPoints,4)>0; $level++)
|
195 |
+
{
|
196 |
+
//définition du parrain
|
197 |
+
$sponsor = Mage::getModel('customer/customer')->load($sponsorId);
|
198 |
+
|
199 |
+
//si parrain a un taux special : on met fin à la boucle
|
200 |
+
$special_rate = $sponsor->getData('special_rate');
|
201 |
+
if ($special_rate)
|
202 |
+
$SPoints = 0;//mise à 0 des points de parrainage pour arrêter la boucle
|
203 |
+
|
204 |
+
$iSPoints = $sponsor->getData('sponsor_points');
|
205 |
+
|
206 |
+
//ajout des points fidélité au parrain
|
207 |
+
//si il y a un taux special et qu'on est au premier niveau
|
208 |
+
$pointsToAdd = 0;
|
209 |
+
if ($special_rate && $level == 0)
|
210 |
+
{
|
211 |
+
$pointsToAdd = $specialSponsorPoints;
|
212 |
+
}
|
213 |
+
//si il n'y a pas de taux special
|
214 |
+
elseif (!$special_rate)
|
215 |
+
{
|
216 |
+
$pointsToAdd = $SPoints;
|
217 |
+
}
|
218 |
+
$tSPoints = $pointsToAdd+$iSPoints;
|
219 |
+
|
220 |
+
if (!$special_rate||($special_rate && $level == 0))
|
221 |
+
{
|
222 |
+
$sponsor->setSponsorPoints($tSPoints);
|
223 |
+
$sponsor->save();
|
224 |
+
|
225 |
+
//enregistrement dans les logs
|
226 |
+
$log = Mage::getModel('sponsorship/sponsorlog');
|
227 |
+
$data = array(
|
228 |
+
'godson_id' => $godsonId,
|
229 |
+
'sponsor_id' => $sponsorId,
|
230 |
+
'record_id' => $orderId,
|
231 |
+
'record_type' => 'order',
|
232 |
+
'datetime' => $orderDate,
|
233 |
+
'points' => $pointsToAdd
|
234 |
+
);
|
235 |
+
// affecter les attributs au nouveau produit
|
236 |
+
$log->setData($data);
|
237 |
+
// sauver le nouveau produit (insère en base de données)
|
238 |
+
$log->save();
|
239 |
+
}
|
240 |
+
if (!$special_rate)
|
241 |
+
{
|
242 |
+
//incrémentation des points à ajouter
|
243 |
+
$SPoints = ($SPoints*$ratio)/100;
|
244 |
+
//le parrain devient le filleul
|
245 |
+
$godsonId = $sponsorId;
|
246 |
+
//définition du parrain du parrain
|
247 |
+
$sponsorId = $this->getSponsorId($sponsorId);
|
248 |
+
}
|
249 |
+
}
|
250 |
+
}
|
251 |
+
|
252 |
+
public function getSponsorId($cId)
|
253 |
+
{
|
254 |
+
$customer = Mage::getModel('customer/customer')->load($cId);
|
255 |
+
$sponsorId = $customer->getSponsor();
|
256 |
+
if ($sponsorId != null && $sponsorId != 0)
|
257 |
+
{
|
258 |
+
return $sponsorId;
|
259 |
+
}
|
260 |
+
else {
|
261 |
+
return false;
|
262 |
+
}
|
263 |
+
}
|
264 |
+
|
265 |
+
public function setSponsor($observer)
|
266 |
+
{
|
267 |
+
//checkout_type_onepage_save_order_after
|
268 |
+
$quote = $observer['quote'];
|
269 |
+
$order = $observer['order'];
|
270 |
+
|
271 |
+
//si c'est un enregistrement (nouveau client)
|
272 |
+
if ($quote->getData('checkout_method')==Mage_Sales_Model_Quote::CHECKOUT_METHOD_REGISTER)
|
273 |
+
{
|
274 |
+
//recherche d'un parrain éventuel
|
275 |
+
$customerId = $order->getCustomerId();
|
276 |
+
if ($customerId != '')
|
277 |
+
{
|
278 |
+
$customer = mage::getModel("customer/customer")->load($customerId);
|
279 |
+
$sponsorId = mage::helper("sponsorship/data")->searchSponsorId($customer->getEmail());
|
280 |
+
if ($sponsorId != '')
|
281 |
+
{
|
282 |
+
$customer->setData('sponsor',$sponsorId);
|
283 |
+
$cookie = new Mage_Core_Model_Cookie;
|
284 |
+
if ($cookie->get('sponsorship_id'))
|
285 |
+
{
|
286 |
+
$cookie->delete('sponsorship_id');
|
287 |
+
$cookie->delete('sponsorship_email');
|
288 |
+
$cookie->delete('sponsorship_firstname');
|
289 |
+
$cookie->delete('sponsorship_lastname');
|
290 |
+
}
|
291 |
+
$customer->save();
|
292 |
+
}
|
293 |
+
}
|
294 |
+
}
|
295 |
+
}
|
296 |
+
|
297 |
+
/*
|
298 |
+
* Add sponsor points for a sponsor with special rate
|
299 |
+
*/
|
300 |
+
public function addSponsorSpecialPoints($cId, $orderDate, $orderId, $orderTotal, $special_rate)
|
301 |
+
{
|
302 |
+
//recalcul de la commande & maj items de la commande
|
303 |
+
try {
|
304 |
+
$sponsorId = $this->getSponsorId($cId);
|
305 |
+
$godsonId = $cId;
|
306 |
+
//définition du parrain
|
307 |
+
$sponsor = Mage::getModel('customer/customer')->load($sponsorId);
|
308 |
+
$iSPoints = $sponsor->getData('sponsor_points');
|
309 |
+
$pointsToAdd = $orderTotal*$special_rate/100;
|
310 |
+
$tSPoints = $pointsToAdd+$iSPoints;
|
311 |
+
$sponsor->setSponsorPoints($tSPoints);
|
312 |
+
$sponsor->save();
|
313 |
+
|
314 |
+
//enregistrement dans les logs
|
315 |
+
$log = Mage::getModel('sponsorship/sponsorlog');
|
316 |
+
$data = array(
|
317 |
+
'godson_id' => $godsonId,
|
318 |
+
'sponsor_id' => $sponsorId,
|
319 |
+
'record_id' => $orderId,
|
320 |
+
'record_type' => 'order',
|
321 |
+
'datetime' => $orderDate,
|
322 |
+
'points' => $pointsToAdd
|
323 |
+
);
|
324 |
+
// affecter les attributs au nouveau produit
|
325 |
+
$log->setData($data);
|
326 |
+
// sauver le nouveau produit (insère en base de données)
|
327 |
+
$log->save();
|
328 |
+
}
|
329 |
+
catch (Exception $e) {
|
330 |
+
Mage::log("An error occured while saving special points :".$e->getMessage());
|
331 |
+
}
|
332 |
+
|
333 |
+
}
|
334 |
+
}
|
app/code/community/Auguria/Sponsorship/Model/Sponsorlog.php
ADDED
@@ -0,0 +1,15 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* @category Auguria
|
4 |
+
* @package Auguria_Sponsorship
|
5 |
+
* @author Auguria
|
6 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
7 |
+
*/
|
8 |
+
class Auguria_Sponsorship_Model_SponsorLog extends Mage_Core_Model_Abstract
|
9 |
+
{
|
10 |
+
public function _construct()
|
11 |
+
{
|
12 |
+
parent::_construct();
|
13 |
+
$this->_init('sponsorship/sponsorlog');
|
14 |
+
}
|
15 |
+
}
|
app/code/community/Auguria/Sponsorship/Model/Sponsorship.php
ADDED
@@ -0,0 +1,15 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* @category Auguria
|
4 |
+
* @package Auguria_Sponsorship
|
5 |
+
* @author Auguria
|
6 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
7 |
+
*/
|
8 |
+
class Auguria_Sponsorship_Model_Sponsorship extends Mage_Core_Model_Abstract
|
9 |
+
{
|
10 |
+
public function _construct()
|
11 |
+
{
|
12 |
+
parent::_construct();
|
13 |
+
$this->_init('sponsorship/sponsorship');
|
14 |
+
}
|
15 |
+
}
|
app/code/community/Auguria/Sponsorship/Model/Status.php
ADDED
@@ -0,0 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* @category Auguria
|
4 |
+
* @package Auguria_Sponsorship
|
5 |
+
* @author Auguria
|
6 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
7 |
+
*/
|
8 |
+
class Auguria_Sponsorship_Model_Status extends Varien_Object
|
9 |
+
{
|
10 |
+
const STATUS_ENABLED = 1;
|
11 |
+
const STATUS_DISABLED = 2;
|
12 |
+
|
13 |
+
static public function getOptionArray()
|
14 |
+
{
|
15 |
+
return array(
|
16 |
+
self::STATUS_ENABLED => Mage::helper('sponsorship')->__('Enabled'),
|
17 |
+
self::STATUS_DISABLED => Mage::helper('sponsorship')->__('Disabled')
|
18 |
+
);
|
19 |
+
}
|
20 |
+
}
|
app/code/community/Auguria/Sponsorship/Model/Validator.php
ADDED
@@ -0,0 +1,253 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* @category Auguria
|
4 |
+
* @package Auguria_Sponsorship
|
5 |
+
* @author Auguria
|
6 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
7 |
+
*/
|
8 |
+
class Auguria_Sponsorship_Model_Validator extends Mage_SalesRule_Model_Validator
|
9 |
+
{
|
10 |
+
protected function _construct()
|
11 |
+
{
|
12 |
+
Mage_Core_Model_Abstract::_construct();
|
13 |
+
$this->_init('salesrule/validator');
|
14 |
+
}
|
15 |
+
|
16 |
+
public function process(Mage_Sales_Model_Quote_Item_Abstract $item)
|
17 |
+
{
|
18 |
+
$item->setDiscountAmount(0);
|
19 |
+
$item->setBaseDiscountAmount(0);
|
20 |
+
$item->setDiscountPercent(0);
|
21 |
+
$item->setCartFidelityPoints(0);
|
22 |
+
$item->setCartSponsorPoints(0);
|
23 |
+
$quote = $item->getQuote();
|
24 |
+
$address = $this->_getAddress($item);
|
25 |
+
|
26 |
+
//Clearing applied rule ids for quote and address
|
27 |
+
if ($this->_isFirstTimeProcessRun !== true){
|
28 |
+
$this->_isFirstTimeProcessRun = true;
|
29 |
+
$quote->setAppliedRuleIds('');
|
30 |
+
$address->setAppliedRuleIds('');
|
31 |
+
}
|
32 |
+
|
33 |
+
$itemPrice = $item->getDiscountCalculationPrice();
|
34 |
+
if ($itemPrice !== null) {
|
35 |
+
$baseItemPrice = $item->getBaseDiscountCalculationPrice();
|
36 |
+
} else {
|
37 |
+
$itemPrice = $item->getCalculationPrice();
|
38 |
+
$baseItemPrice = $item->getBaseCalculationPrice();
|
39 |
+
}
|
40 |
+
|
41 |
+
$appliedRuleIds = array();
|
42 |
+
foreach ($this->_getRules() as $rule) {
|
43 |
+
/* @var $rule Mage_SalesRule_Model_Rule */
|
44 |
+
if (!$this->_canProcessRule($rule, $address)) {
|
45 |
+
continue;
|
46 |
+
}
|
47 |
+
|
48 |
+
if (!$rule->getActions()->validate($item)) {
|
49 |
+
continue;
|
50 |
+
}
|
51 |
+
$qty = $item->getTotalQty();
|
52 |
+
$qty = $rule->getDiscountQty() ? min($qty, $rule->getDiscountQty()) : $qty;
|
53 |
+
$rulePercent = min(100, $rule->getDiscountAmount());
|
54 |
+
|
55 |
+
$discountAmount = 0;
|
56 |
+
$baseDiscountAmount = 0;
|
57 |
+
$cartFidelityPoints = 0;
|
58 |
+
$cartSponsorPoints = 0;
|
59 |
+
switch ($rule->getSimpleAction()) {
|
60 |
+
case 'to_percent':
|
61 |
+
$rulePercent = max(0, 100-$rule->getDiscountAmount());
|
62 |
+
//no break;
|
63 |
+
case 'by_percent':
|
64 |
+
$step = $rule->getDiscountStep();
|
65 |
+
if ($step) {
|
66 |
+
$qty = floor($qty/$step)*$step;
|
67 |
+
}
|
68 |
+
$discountAmount = ($qty*$itemPrice - $item->getDiscountAmount()) * $rulePercent/100;
|
69 |
+
$baseDiscountAmount= ($qty*$baseItemPrice - $item->getBaseDiscountAmount()) * $rulePercent/100;
|
70 |
+
|
71 |
+
if (!$rule->getDiscountQty() || $rule->getDiscountQty()>$qty) {
|
72 |
+
$discountPercent = min(100, $item->getDiscountPercent()+$rulePercent);
|
73 |
+
$item->setDiscountPercent($discountPercent);
|
74 |
+
}
|
75 |
+
break;
|
76 |
+
case 'to_fixed':
|
77 |
+
$quoteAmount = $quote->getStore()->convertPrice($rule->getDiscountAmount());
|
78 |
+
$discountAmount = $qty*($itemPrice-$quoteAmount);
|
79 |
+
$baseDiscountAmount= $qty*($baseItemPrice-$rule->getDiscountAmount());
|
80 |
+
break;
|
81 |
+
|
82 |
+
case 'by_fixed':
|
83 |
+
$step = $rule->getDiscountStep();
|
84 |
+
if ($step) {
|
85 |
+
$qty = floor($qty/$step)*$step;
|
86 |
+
}
|
87 |
+
$quoteAmount = $quote->getStore()->convertPrice($rule->getDiscountAmount());
|
88 |
+
$discountAmount = $qty*$quoteAmount;
|
89 |
+
$baseDiscountAmount = $qty*$rule->getDiscountAmount();
|
90 |
+
break;
|
91 |
+
|
92 |
+
case 'cart_fixed':
|
93 |
+
$cartRules = $address->getCartFixedRules();
|
94 |
+
if (!isset($cartRules[$rule->getId()])) {
|
95 |
+
$cartRules[$rule->getId()] = $rule->getDiscountAmount();
|
96 |
+
}
|
97 |
+
if ($cartRules[$rule->getId()] > 0) {
|
98 |
+
$quoteAmount = $quote->getStore()->convertPrice($cartRules[$rule->getId()]);
|
99 |
+
/**
|
100 |
+
* We can't use row total here because row total not include tax
|
101 |
+
*/
|
102 |
+
$discountAmount = min($itemPrice*$qty - $item->getDiscountAmount(), $quoteAmount);
|
103 |
+
$baseDiscountAmount = min($baseItemPrice*$qty - $item->getBaseDiscountAmount(), $cartRules[$rule->getId()]);
|
104 |
+
$cartRules[$rule->getId()] -= $baseDiscountAmount;
|
105 |
+
}
|
106 |
+
$address->setCartFixedRules($cartRules);
|
107 |
+
break;
|
108 |
+
|
109 |
+
case 'buy_x_get_y':
|
110 |
+
$x = $rule->getDiscountStep();
|
111 |
+
$y = $rule->getDiscountAmount();
|
112 |
+
if (!$x || $y>=$x) {
|
113 |
+
break;
|
114 |
+
}
|
115 |
+
$buy = 0; $free = 0;
|
116 |
+
while ($buy+$free<$qty) {
|
117 |
+
$buy += $x;
|
118 |
+
if ($buy+$free>=$qty) {
|
119 |
+
break;
|
120 |
+
}
|
121 |
+
$free += min($y, $qty-$buy-$free);
|
122 |
+
if ($buy+$free>=$qty) {
|
123 |
+
break;
|
124 |
+
}
|
125 |
+
}
|
126 |
+
$discountAmount = $free*$itemPrice;
|
127 |
+
$baseDiscountAmount= $free*$baseItemPrice;
|
128 |
+
break;
|
129 |
+
|
130 |
+
//début case perso-------------------------------------------------------------------
|
131 |
+
//fielity
|
132 |
+
case 'fidelity_points_by_fixed':
|
133 |
+
if ($step = $rule->getDiscountStep()) {
|
134 |
+
$qty = floor($qty/$step)*$step;
|
135 |
+
}
|
136 |
+
$cartFidelityPoints = $qty*$rule->getDiscountAmount();
|
137 |
+
break;
|
138 |
+
|
139 |
+
case 'fidelity_points_by_percent':
|
140 |
+
if ($step = $rule->getDiscountStep()) {
|
141 |
+
$qty = floor($qty/$step)*$step;
|
142 |
+
}
|
143 |
+
$cartFidelityPoints = ($qty * ($item->getBaseCalculationPrice() - $item->getBaseDiscountAmount())) * $rulePercent/100;
|
144 |
+
break;
|
145 |
+
|
146 |
+
case 'fidelity_points_cart_fixed':
|
147 |
+
$cartRules = $address->getCartFixedRules();
|
148 |
+
if (!isset($cartRules[$rule->getId()])) {
|
149 |
+
$cartRules[$rule->getId()] = $rule->getDiscountAmount();
|
150 |
+
}
|
151 |
+
if ($cartRules[$rule->getId()] > 0) {
|
152 |
+
$cartFidelityPoints = max($item->getCartFidelityPoints(), $cartRules[$rule->getId()]);
|
153 |
+
$cartRules[$rule->getId()] -= $cartFidelityPoints;
|
154 |
+
}
|
155 |
+
$address->setCartFixedRules($cartRules);
|
156 |
+
break;
|
157 |
+
//sponsor
|
158 |
+
case 'sponsor_points_by_fixed':
|
159 |
+
if ($step = $rule->getDiscountStep()) {
|
160 |
+
$qty = floor($qty/$step)*$step;
|
161 |
+
}
|
162 |
+
$cartSponsorPoints = $qty*$rule->getDiscountAmount();
|
163 |
+
break;
|
164 |
+
|
165 |
+
case 'sponsor_points_by_percent':
|
166 |
+
if ($step = $rule->getDiscountStep()) {
|
167 |
+
$qty = floor($qty/$step)*$step;
|
168 |
+
}
|
169 |
+
$cartSponsorPoints = ($qty * ($item->getBaseCalculationPrice() - $item->getBaseDiscountAmount())) * $rulePercent/100;
|
170 |
+
break;
|
171 |
+
|
172 |
+
case 'sponsor_points_cart_fixed':
|
173 |
+
$cartRules = $address->getCartFixedRules();
|
174 |
+
if (!isset($cartRules[$rule->getId()])) {
|
175 |
+
$cartRules[$rule->getId()] = $rule->getDiscountAmount();
|
176 |
+
}
|
177 |
+
if ($cartRules[$rule->getId()] > 0) {
|
178 |
+
$cartSponsorPoints = max($item->getCartFidelityPoints(), $cartRules[$rule->getId()]);
|
179 |
+
$cartRules[$rule->getId()] -= $cartSponsorPoints;
|
180 |
+
}
|
181 |
+
$address->setCartFixedRules($cartRules);
|
182 |
+
break;
|
183 |
+
//fin case perso-------------------------------------------------------------------
|
184 |
+
}
|
185 |
+
$result = new Varien_Object(array(
|
186 |
+
'discount_amount' => $discountAmount,
|
187 |
+
'base_discount_amount' => $baseDiscountAmount,
|
188 |
+
'cart_fidelity_points' => $cartFidelityPoints,
|
189 |
+
'cart_sponsor_points' => $cartSponsorPoints,
|
190 |
+
));
|
191 |
+
Mage::dispatchEvent('salesrule_validator_process', array(
|
192 |
+
'rule' => $rule,
|
193 |
+
'item' => $item,
|
194 |
+
'address' => $address,
|
195 |
+
'quote' => $quote,
|
196 |
+
'qty' => $qty,
|
197 |
+
'result' => $result,
|
198 |
+
));
|
199 |
+
|
200 |
+
$discountAmount = $result->getDiscountAmount();
|
201 |
+
$baseDiscountAmount = $result->getBaseDiscountAmount();
|
202 |
+
|
203 |
+
//On garde uniquement la règle qui apporte leplus de points
|
204 |
+
$cartFidelityPoints = max($item->getCartFidelityPoints(), $cartFidelityPoints);
|
205 |
+
$cartSponsorPoints = max($item->getCartSponsorPoints(), $cartSponsorPoints);
|
206 |
+
|
207 |
+
$percentKey = $item->getDiscountPercent();
|
208 |
+
/**
|
209 |
+
* Process "delta" rounding
|
210 |
+
*/
|
211 |
+
if ($percentKey) {
|
212 |
+
$delta = isset($this->_roundingDeltas[$percentKey]) ? $this->_roundingDeltas[$percentKey] : 0;
|
213 |
+
$baseDelta = isset($this->_baseRoundingDeltas[$percentKey]) ? $this->_baseRoundingDeltas[$percentKey] : 0;
|
214 |
+
$discountAmount+= $delta;
|
215 |
+
$baseDiscountAmount+=$baseDelta;
|
216 |
+
|
217 |
+
$this->_roundingDeltas[$percentKey] = $discountAmount - $quote->getStore()->roundPrice($discountAmount);
|
218 |
+
$this->_baseRoundingDeltas[$percentKey] = $baseDiscountAmount - $quote->getStore()->roundPrice($baseDiscountAmount);
|
219 |
+
$discountAmount = $quote->getStore()->roundPrice($discountAmount);
|
220 |
+
$baseDiscountAmount = $quote->getStore()->roundPrice($baseDiscountAmount);
|
221 |
+
} else {
|
222 |
+
$discountAmount = $quote->getStore()->roundPrice($discountAmount);
|
223 |
+
$baseDiscountAmount = $quote->getStore()->roundPrice($baseDiscountAmount);
|
224 |
+
}
|
225 |
+
|
226 |
+
/**
|
227 |
+
* We can't use row total here because row total not include tax
|
228 |
+
* Discount can be applied on price included tax
|
229 |
+
*/
|
230 |
+
$discountAmount = min($item->getDiscountAmount()+$discountAmount, $itemPrice*$qty);
|
231 |
+
$baseDiscountAmount = min($item->getBaseDiscountAmount()+$baseDiscountAmount, $baseItemPrice*$qty);
|
232 |
+
|
233 |
+
$item->setDiscountAmount($discountAmount);
|
234 |
+
$item->setBaseDiscountAmount($baseDiscountAmount);
|
235 |
+
$item->setCartFidelityPoints($cartFidelityPoints);
|
236 |
+
$item->setCartSponsorPoints($cartSponsorPoints);
|
237 |
+
|
238 |
+
$appliedRuleIds[$rule->getRuleId()] = $rule->getRuleId();
|
239 |
+
|
240 |
+
if ($rule->getCouponCode() && ( strtolower($rule->getCouponCode()) == strtolower($this->getCouponCode()))) {
|
241 |
+
$address->setCouponCode($this->getCouponCode());
|
242 |
+
}
|
243 |
+
$this->_addDiscountDescription($address, $rule);
|
244 |
+
if ($rule->getStopRulesProcessing()) {
|
245 |
+
break;
|
246 |
+
}
|
247 |
+
}
|
248 |
+
$item->setAppliedRuleIds(join(',',$appliedRuleIds));
|
249 |
+
$address->setAppliedRuleIds($this->mergeIds($address->getAppliedRuleIds(), $appliedRuleIds));
|
250 |
+
$quote->setAppliedRuleIds($this->mergeIds($quote->getAppliedRuleIds(), $appliedRuleIds));
|
251 |
+
return $this;
|
252 |
+
}
|
253 |
+
}
|
app/code/community/Auguria/Sponsorship/controllers/Adminhtml/ChangeController.php
ADDED
@@ -0,0 +1,278 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* @category Auguria
|
4 |
+
* @package Auguria_Sponsorship
|
5 |
+
* @author Auguria
|
6 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
7 |
+
*/
|
8 |
+
class Auguria_Sponsorship_Adminhtml_ChangeController extends Mage_Adminhtml_Controller_action
|
9 |
+
{
|
10 |
+
|
11 |
+
protected function _initAction() {
|
12 |
+
$this->loadLayout()
|
13 |
+
->_setActiveMenu('change/items')
|
14 |
+
->_addBreadcrumb(Mage::helper('adminhtml')->__('Items Manager'), Mage::helper('adminhtml')->__('Item Manager'));
|
15 |
+
|
16 |
+
return $this;
|
17 |
+
}
|
18 |
+
|
19 |
+
public function indexAction() {
|
20 |
+
$this->_initAction()
|
21 |
+
->renderLayout();
|
22 |
+
}
|
23 |
+
|
24 |
+
public function editAction() {
|
25 |
+
$id = $this->getRequest()->getParam('id');
|
26 |
+
$model = Mage::getModel('sponsorship/change')->load($id);
|
27 |
+
|
28 |
+
if ($model->getId() || $id == 0) {
|
29 |
+
$data = Mage::getSingleton('adminhtml/session')->getFormData(true);
|
30 |
+
if (!empty($data)) {
|
31 |
+
$model->setData($data);
|
32 |
+
}
|
33 |
+
Mage::register('change_data', $model);
|
34 |
+
|
35 |
+
$this->loadLayout();
|
36 |
+
$this->_setActiveMenu('change/items');
|
37 |
+
|
38 |
+
$this->_addBreadcrumb(Mage::helper('adminhtml')->__('Item Manager'), Mage::helper('adminhtml')->__('Item Manager'));
|
39 |
+
$this->_addBreadcrumb(Mage::helper('adminhtml')->__('Item News'), Mage::helper('adminhtml')->__('Item News'));
|
40 |
+
|
41 |
+
$this->getLayout()->getBlock('head')->setCanLoadExtJs(true);
|
42 |
+
|
43 |
+
$this->_addContent($this->getLayout()->createBlock('sponsorship/adminhtml_change_edit'))
|
44 |
+
->_addLeft($this->getLayout()->createBlock('sponsorship/adminhtml_change_edit_tabs'));
|
45 |
+
|
46 |
+
$this->renderLayout();
|
47 |
+
} else {
|
48 |
+
Mage::getSingleton('adminhtml/session')->addError(Mage::helper('sponsorship')->__("This change doesn't exist"));
|
49 |
+
$this->_redirect('*/*/');
|
50 |
+
}
|
51 |
+
}
|
52 |
+
|
53 |
+
public function saveAction() {
|
54 |
+
if ($cdata = $this->getRequest()->getPost()) {
|
55 |
+
|
56 |
+
if(isset($_FILES['filename']['name']) && $_FILES['filename']['name'] != '') {
|
57 |
+
try {
|
58 |
+
/* Starting upload */
|
59 |
+
$uploader = new Varien_File_Uploader('filename');
|
60 |
+
|
61 |
+
// Any extention would work
|
62 |
+
$uploader->setAllowedExtensions(array('jpg','jpeg','gif','png'));
|
63 |
+
$uploader->setAllowRenameFiles(false);
|
64 |
+
|
65 |
+
// Set the file upload mode
|
66 |
+
// false -> get the file directly in the specified folder
|
67 |
+
// true -> get the file in the product like folders
|
68 |
+
// (file.jpg will go in something like /media/f/i/file.jpg)
|
69 |
+
$uploader->setFilesDispersion(false);
|
70 |
+
|
71 |
+
// We set media as the upload dir
|
72 |
+
$path = Mage::getBaseDir('media') . DS ;
|
73 |
+
$uploader->save($path, $_FILES['filename']['name'] );
|
74 |
+
|
75 |
+
} catch (Exception $e) {
|
76 |
+
|
77 |
+
}
|
78 |
+
|
79 |
+
//this way the name is saved in DB
|
80 |
+
$cdata['filename'] = $_FILES['filename']['name'];
|
81 |
+
}
|
82 |
+
|
83 |
+
try {
|
84 |
+
|
85 |
+
//Enregistrements spécifiques à une annulation---------------------------
|
86 |
+
$changeId = $this->getRequest()->getParam('id');
|
87 |
+
$this->statusCanceled ($changeId,$cdata['statut']);
|
88 |
+
|
89 |
+
//Enregistrement dans la table "change"
|
90 |
+
$model = Mage::getModel('sponsorship/change');
|
91 |
+
$model->setData($cdata)
|
92 |
+
->setId($this->getRequest()->getParam('id'));
|
93 |
+
$model->save();
|
94 |
+
|
95 |
+
|
96 |
+
Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('sponsorship')->__("The change has been successfully recorded"));
|
97 |
+
Mage::getSingleton('adminhtml/session')->setFormData(false);
|
98 |
+
|
99 |
+
if ($this->getRequest()->getParam('back')) {
|
100 |
+
$this->_redirect('*/*/edit', array('id' => $model->getId()));
|
101 |
+
return;
|
102 |
+
}
|
103 |
+
$this->_redirect('*/*/');
|
104 |
+
return;
|
105 |
+
} catch (Exception $e) {
|
106 |
+
Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
|
107 |
+
Mage::getSingleton('adminhtml/session')->setFormData($data);
|
108 |
+
$this->_redirect('*/*/edit', array('id' => $this->getRequest()->getParam('id')));
|
109 |
+
return;
|
110 |
+
}
|
111 |
+
}
|
112 |
+
Mage::getSingleton('adminhtml/session')->addError(Mage::helper('sponsorship')->__("Unable to find change to save"));
|
113 |
+
$this->_redirect('*/*/');
|
114 |
+
}
|
115 |
+
|
116 |
+
public function massStatusAction()
|
117 |
+
{
|
118 |
+
$sponsorshipIds = $this->getRequest()->getParam('change');
|
119 |
+
if(!is_array($sponsorshipIds)) {
|
120 |
+
Mage::getSingleton('adminhtml/session')->addError(Mage::helper('sponsorship')->__("Please select changes"));
|
121 |
+
} else {
|
122 |
+
try {
|
123 |
+
foreach ($sponsorshipIds as $sponsorshipId) {
|
124 |
+
|
125 |
+
//Enregistrements spécifiques à une annulation---------------------------
|
126 |
+
$this->statusCanceled ($sponsorshipId,$this->getRequest()->getParam('statut'));
|
127 |
+
|
128 |
+
//Enregistrements dans change
|
129 |
+
$sponsorship = Mage::getSingleton('sponsorship/change')
|
130 |
+
->load($sponsorshipId)
|
131 |
+
->setStatut($this->getRequest()->getParam('statut'))
|
132 |
+
->setIsMassupdate(true)
|
133 |
+
->save();
|
134 |
+
}
|
135 |
+
$this->_getSession()->addSuccess(
|
136 |
+
$this->__('Total of %d record(s) were successfully updated', count($sponsorshipIds))
|
137 |
+
);
|
138 |
+
} catch (Exception $e) {
|
139 |
+
$this->_getSession()->addError($e->getMessage());
|
140 |
+
}
|
141 |
+
}
|
142 |
+
$this->_redirect('*/*/index');
|
143 |
+
}
|
144 |
+
|
145 |
+
public function exportCsvAction()
|
146 |
+
{
|
147 |
+
$fileName = 'sponsorshipChange.csv';
|
148 |
+
$content = $this->getLayout()->createBlock('sponsorship/adminhtml_change_grid')
|
149 |
+
->getCsv();
|
150 |
+
$this->_sendUploadResponse($fileName, $content);
|
151 |
+
}
|
152 |
+
|
153 |
+
public function exportXmlAction()
|
154 |
+
{
|
155 |
+
$fileName = 'sponsorshipChange.xml';
|
156 |
+
$content = $this->getLayout()->createBlock('sponsorship/adminhtml_change_grid')
|
157 |
+
->getXml();
|
158 |
+
|
159 |
+
$this->_sendUploadResponse($fileName, $content);
|
160 |
+
}
|
161 |
+
|
162 |
+
protected function _sendUploadResponse($fileName, $content, $contentType='application/octet-stream')
|
163 |
+
{
|
164 |
+
$response = $this->getResponse();
|
165 |
+
$response->setHeader('HTTP/1.1 200 OK','');
|
166 |
+
$response->setHeader('Pragma', 'public', true);
|
167 |
+
$response->setHeader('Cache-Control', 'must-revalidate, post-check=0, pre-check=0', true);
|
168 |
+
$response->setHeader('Content-Disposition', 'attachment; filename='.$fileName);
|
169 |
+
$response->setHeader('Last-Modified', date('r'));
|
170 |
+
$response->setHeader('Accept-Ranges', 'bytes');
|
171 |
+
$response->setHeader('Content-Length', strlen($content));
|
172 |
+
$response->setHeader('Content-type', $contentType);
|
173 |
+
$response->setBody($content);
|
174 |
+
$response->sendResponse();
|
175 |
+
die;
|
176 |
+
}
|
177 |
+
|
178 |
+
protected function statusCanceled ($changeId, $statut)
|
179 |
+
{
|
180 |
+
$model = Mage::getSingleton('sponsorship/change');
|
181 |
+
$model->load($changeId);
|
182 |
+
|
183 |
+
//si statut passe à annulé
|
184 |
+
if ($model->getStatut() != 'canceled' && $statut == 'canceled')
|
185 |
+
{
|
186 |
+
//Ajustement en fonction du module (Fidelity ou Sponsor)
|
187 |
+
$module = $model->getModule();
|
188 |
+
$points = $model->getPoints();
|
189 |
+
|
190 |
+
$Module = ucfirst($module);
|
191 |
+
$setPoints = 'set'.$Module.'Points';
|
192 |
+
$getPoints = 'get'.$Module.'Points';
|
193 |
+
|
194 |
+
//Mise à jour des points sur le client
|
195 |
+
$cId = $model->getCustomerId();
|
196 |
+
|
197 |
+
$customer = Mage::getModel('customer/customer')->load($cId);
|
198 |
+
$cPoints = $customer->$getPoints();
|
199 |
+
$customer->$setPoints($cPoints+$points);
|
200 |
+
$customer->save();
|
201 |
+
|
202 |
+
//Mise à jour des logs
|
203 |
+
$log = Mage::getModel('sponsorship/'.$module.'log');
|
204 |
+
$dateTime = Mage::getModel('core/date')->date();
|
205 |
+
if ($module == 'fidelity')
|
206 |
+
{
|
207 |
+
$data = array(
|
208 |
+
'customer_id' => $cId,
|
209 |
+
'record_id' => $changeId,
|
210 |
+
'record_type' => 'admin',
|
211 |
+
'datetime' => $dateTime,
|
212 |
+
'points' => $points
|
213 |
+
);
|
214 |
+
}
|
215 |
+
elseif ($module == 'sponsor')
|
216 |
+
{
|
217 |
+
$data = array(
|
218 |
+
'godson_id' => $cId,
|
219 |
+
'sponsor_id' => $cId,
|
220 |
+
'record_id' => $changeId,
|
221 |
+
'record_type' => 'admin',
|
222 |
+
'datetime' => $dateTime,
|
223 |
+
'points' => $points
|
224 |
+
);
|
225 |
+
}
|
226 |
+
$log->setData($data);
|
227 |
+
$log->save();
|
228 |
+
|
229 |
+
}
|
230 |
+
//si statut passe de annulé à autre
|
231 |
+
elseif ($model->getStatut() == 'canceled' && $statut != 'canceled')
|
232 |
+
{
|
233 |
+
|
234 |
+
//Ajustement en fonction du module (Fidelity ou Sponsor)
|
235 |
+
$module = $model->getModule();
|
236 |
+
$points = $model->getPoints();
|
237 |
+
|
238 |
+
$Module = ucfirst($module);
|
239 |
+
$setPoints = 'set'.$Module.'Points';
|
240 |
+
$getPoints = 'get'.$Module.'Points';
|
241 |
+
|
242 |
+
//Mise à jour des points sur le client
|
243 |
+
$cId = $model->getCustomerId();
|
244 |
+
|
245 |
+
$customer = Mage::getModel('customer/customer')->load($cId);
|
246 |
+
$cPoints = $customer->$getPoints();
|
247 |
+
$customer->$setPoints($cPoints-$points);
|
248 |
+
$customer->save();
|
249 |
+
|
250 |
+
//Mise à jour des logs
|
251 |
+
$log = Mage::getModel('sponsorship/'.$module.'log');
|
252 |
+
$dateTime = Mage::getModel('core/date')->date();
|
253 |
+
if ($module == 'fidelity')
|
254 |
+
{
|
255 |
+
$data = array(
|
256 |
+
'customer_id' => $cId,
|
257 |
+
'record_id' => $changeId,
|
258 |
+
'record_type' => 'admin',
|
259 |
+
'datetime' => $dateTime,
|
260 |
+
'points' => -$points
|
261 |
+
);
|
262 |
+
}
|
263 |
+
elseif ($module == 'sponsor')
|
264 |
+
{
|
265 |
+
$data = array(
|
266 |
+
'godson_id' => $cId,
|
267 |
+
'sponsor_id' => $cId,
|
268 |
+
'record_id' => $changeId,
|
269 |
+
'record_type' => 'admin',
|
270 |
+
'datetime' => $dateTime,
|
271 |
+
'points' => -$points
|
272 |
+
);
|
273 |
+
}
|
274 |
+
$log->setData($data);
|
275 |
+
$log->save();
|
276 |
+
}
|
277 |
+
}
|
278 |
+
}
|
app/code/community/Auguria/Sponsorship/controllers/Adminhtml/LinkController.php
ADDED
@@ -0,0 +1,144 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* @category Auguria
|
4 |
+
* @package Auguria_Sponsorship
|
5 |
+
* @author Auguria
|
6 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
7 |
+
*/
|
8 |
+
class Auguria_Sponsorship_Adminhtml_LinkController extends Mage_Adminhtml_Controller_action
|
9 |
+
{
|
10 |
+
|
11 |
+
protected function _initAction() {
|
12 |
+
$this->loadLayout()
|
13 |
+
->_setActiveMenu('link/items')
|
14 |
+
->_addBreadcrumb(Mage::helper('adminhtml')->__('Items Manager'), Mage::helper('adminhtml')->__('Item Manager'));
|
15 |
+
|
16 |
+
return $this;
|
17 |
+
}
|
18 |
+
|
19 |
+
public function indexAction() {
|
20 |
+
$this->_initAction()
|
21 |
+
->renderLayout();
|
22 |
+
}
|
23 |
+
|
24 |
+
public function editAction() {
|
25 |
+
$id = $this->getRequest()->getParam('id');
|
26 |
+
$model = Mage::getModel('customer/customer')->load($id);
|
27 |
+
|
28 |
+
if ($model->getId() || $id == 0) {
|
29 |
+
$data = Mage::getSingleton('adminhtml/session')->getFormData(true);
|
30 |
+
if (!empty($data)) {
|
31 |
+
$model->setData($data);
|
32 |
+
}
|
33 |
+
Mage::register('link_data', $model);
|
34 |
+
|
35 |
+
$this->loadLayout();
|
36 |
+
$this->_setActiveMenu('link/items');
|
37 |
+
|
38 |
+
$this->_addBreadcrumb(Mage::helper('adminhtml')->__('Item Manager'), Mage::helper('adminhtml')->__('Item Manager'));
|
39 |
+
$this->_addBreadcrumb(Mage::helper('adminhtml')->__('Item News'), Mage::helper('adminhtml')->__('Item News'));
|
40 |
+
|
41 |
+
$this->getLayout()->getBlock('head')->setCanLoadExtJs(true);
|
42 |
+
|
43 |
+
$this->_addContent($this->getLayout()->createBlock('sponsorship/adminhtml_link_edit'))
|
44 |
+
->_addLeft($this->getLayout()->createBlock('sponsorship/adminhtml_link_edit_tabs'));
|
45 |
+
|
46 |
+
$this->renderLayout();
|
47 |
+
} else {
|
48 |
+
Mage::getSingleton('adminhtml/session')->addError(Mage::helper('sponsorship')->__("This sponsorship doesn't exist"));
|
49 |
+
$this->_redirect('*/*/');
|
50 |
+
}
|
51 |
+
}
|
52 |
+
public function saveAction()
|
53 |
+
{
|
54 |
+
if ($data = $this->getRequest()->getPost())
|
55 |
+
{
|
56 |
+
try
|
57 |
+
{
|
58 |
+
$model = Mage::getModel('customer/customer')->load($this->getRequest()->getParam('entity_id'));
|
59 |
+
$model->setSponsor($this->getRequest()->getParam('sponsor'));
|
60 |
+
$model->save();
|
61 |
+
Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('sponsorship')->__('Sponsorship was successfully saved'));
|
62 |
+
Mage::getSingleton('adminhtml/session')->setFormData(false);
|
63 |
+
|
64 |
+
if ($this->getRequest()->getParam('back')) {
|
65 |
+
$this->_redirect('*/*/edit', array('id' => $model->getId()));
|
66 |
+
return;
|
67 |
+
}
|
68 |
+
$this->_redirect('*/*/');
|
69 |
+
return;
|
70 |
+
}
|
71 |
+
catch (Exception $e)
|
72 |
+
{
|
73 |
+
Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
|
74 |
+
}
|
75 |
+
Mage::getSingleton('adminhtml/session')->setFormData($data);
|
76 |
+
$this->_redirect('*/*/edit', array('id' => $this->getRequest()->getParam('id')));
|
77 |
+
return;
|
78 |
+
}
|
79 |
+
Mage::getSingleton('adminhtml/session')->addError(Mage::helper('sponsorship')->__('Unable to find sponsorship to save'));
|
80 |
+
$this->_redirect('*/*/');
|
81 |
+
}
|
82 |
+
public function exportCsvAction()
|
83 |
+
{
|
84 |
+
$fileName = 'sponsorship.csv';
|
85 |
+
$content = $this->getLayout()->createBlock('sponsorship/adminhtml_link_grid')
|
86 |
+
->getCsv();
|
87 |
+
|
88 |
+
$this->_sendUploadResponse($fileName, $content);
|
89 |
+
}
|
90 |
+
|
91 |
+
public function exportXmlAction()
|
92 |
+
{
|
93 |
+
$fileName = 'sponsorship.xml';
|
94 |
+
$content = $this->getLayout()->createBlock('sponsorship/adminhtml_link_grid')
|
95 |
+
->getXml();
|
96 |
+
|
97 |
+
$this->_sendUploadResponse($fileName, $content);
|
98 |
+
}
|
99 |
+
protected function _sendUploadResponse($fileName, $content, $contentType='application/octet-stream')
|
100 |
+
{
|
101 |
+
$response = $this->getResponse();
|
102 |
+
$response->setHeader('HTTP/1.1 200 OK','');
|
103 |
+
$response->setHeader('Pragma', 'public', true);
|
104 |
+
$response->setHeader('Cache-Control', 'must-revalidate, post-check=0, pre-check=0', true);
|
105 |
+
$response->setHeader('Content-Disposition', 'attachment; filename='.$fileName);
|
106 |
+
$response->setHeader('Last-Modified', date('r'));
|
107 |
+
$response->setHeader('Accept-Ranges', 'bytes');
|
108 |
+
$response->setHeader('Content-Length', strlen($content));
|
109 |
+
$response->setHeader('Content-type', $contentType);
|
110 |
+
$response->setBody($content);
|
111 |
+
$response->sendResponse();
|
112 |
+
die;
|
113 |
+
}
|
114 |
+
|
115 |
+
public function massDeleteAction()
|
116 |
+
{
|
117 |
+
$sponsorshipIds = $this->getRequest()->getParam('sponsorship');
|
118 |
+
if(!is_array($sponsorshipIds))
|
119 |
+
{
|
120 |
+
Mage::getSingleton('adminhtml/session')->addError(Mage::helper('adminhtml')->__('Please select item(s)'));
|
121 |
+
}
|
122 |
+
else
|
123 |
+
{
|
124 |
+
try
|
125 |
+
{
|
126 |
+
foreach ($sponsorshipIds as $sponsorshipId)
|
127 |
+
{
|
128 |
+
$sponsorship = Mage::getModel('customer/customer')->load($sponsorshipId);
|
129 |
+
$sponsorship->setSponsor("");
|
130 |
+
$sponsorship->save();
|
131 |
+
}
|
132 |
+
Mage::getSingleton('adminhtml/session')->addSuccess(
|
133 |
+
Mage::helper('adminhtml')->__(
|
134 |
+
'Total of %d record(s) were successfully deleted', count($sponsorshipIds)
|
135 |
+
));
|
136 |
+
}
|
137 |
+
catch (Exception $e)
|
138 |
+
{
|
139 |
+
Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
|
140 |
+
}
|
141 |
+
}
|
142 |
+
$this->_redirect('*/*/index');
|
143 |
+
}
|
144 |
+
}
|
app/code/community/Auguria/Sponsorship/controllers/Adminhtml/SponsorshipController.php
ADDED
@@ -0,0 +1,144 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* @category Auguria
|
4 |
+
* @package Auguria_Sponsorship
|
5 |
+
* @author Auguria
|
6 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
7 |
+
*/
|
8 |
+
class Auguria_Sponsorship_Adminhtml_SponsorshipController extends Mage_Adminhtml_Controller_action
|
9 |
+
{
|
10 |
+
|
11 |
+
protected function _initAction() {
|
12 |
+
$this->loadLayout()
|
13 |
+
->_setActiveMenu('sponsorship/items')
|
14 |
+
->_addBreadcrumb(Mage::helper('adminhtml')->__('Items Manager'), Mage::helper('adminhtml')->__('Item Manager'));
|
15 |
+
|
16 |
+
return $this;
|
17 |
+
}
|
18 |
+
|
19 |
+
public function indexAction() {
|
20 |
+
$this->_initAction()
|
21 |
+
->renderLayout();
|
22 |
+
}
|
23 |
+
|
24 |
+
public function editAction() {
|
25 |
+
$id = $this->getRequest()->getParam('id');
|
26 |
+
$model = Mage::getModel('sponsorship/sponsorship')->load($id);
|
27 |
+
|
28 |
+
if ($model->getId() || $id == 0) {
|
29 |
+
$data = Mage::getSingleton('adminhtml/session')->getFormData(true);
|
30 |
+
if (!empty($data)) {
|
31 |
+
$model->setData($data);
|
32 |
+
}
|
33 |
+
|
34 |
+
Mage::register('sponsorship_data', $model);
|
35 |
+
|
36 |
+
$this->loadLayout();
|
37 |
+
$this->_setActiveMenu('sponsorship/items');
|
38 |
+
|
39 |
+
$this->_addBreadcrumb(Mage::helper('adminhtml')->__('Item Manager'), Mage::helper('adminhtml')->__('Item Manager'));
|
40 |
+
$this->_addBreadcrumb(Mage::helper('adminhtml')->__('Item News'), Mage::helper('adminhtml')->__('Item News'));
|
41 |
+
|
42 |
+
$this->getLayout()->getBlock('head')->setCanLoadExtJs(true);
|
43 |
+
|
44 |
+
$this->_addContent($this->getLayout()->createBlock('sponsorship/adminhtml_sponsorship_edit'))
|
45 |
+
->_addLeft($this->getLayout()->createBlock('sponsorship/adminhtml_sponsorship_edit_tabs'));
|
46 |
+
|
47 |
+
$this->renderLayout();
|
48 |
+
} else {
|
49 |
+
Mage::getSingleton('adminhtml/session')->addError(Mage::helper('sponsorship')->__('Invitation does not exist'));
|
50 |
+
$this->_redirect('*/*/');
|
51 |
+
}
|
52 |
+
}
|
53 |
+
|
54 |
+
public function saveAction() {
|
55 |
+
if ($data = $this->getRequest()->getPost()) {
|
56 |
+
|
57 |
+
if(isset($_FILES['filename']['name']) && $_FILES['filename']['name'] != '') {
|
58 |
+
try {
|
59 |
+
/* Starting upload */
|
60 |
+
$uploader = new Varien_File_Uploader('filename');
|
61 |
+
|
62 |
+
// Any extention would work
|
63 |
+
$uploader->setAllowedExtensions(array('jpg','jpeg','gif','png'));
|
64 |
+
$uploader->setAllowRenameFiles(false);
|
65 |
+
|
66 |
+
// Set the file upload mode
|
67 |
+
// false -> get the file directly in the specified folder
|
68 |
+
// true -> get the file in the product like folders
|
69 |
+
// (file.jpg will go in something like /media/f/i/file.jpg)
|
70 |
+
$uploader->setFilesDispersion(false);
|
71 |
+
|
72 |
+
// We set media as the upload dir
|
73 |
+
$path = Mage::getBaseDir('media') . DS ;
|
74 |
+
$uploader->save($path, $_FILES['filename']['name'] );
|
75 |
+
|
76 |
+
} catch (Exception $e) {
|
77 |
+
|
78 |
+
}
|
79 |
+
|
80 |
+
//this way the name is saved in DB
|
81 |
+
$data['filename'] = $_FILES['filename']['name'];
|
82 |
+
}
|
83 |
+
|
84 |
+
|
85 |
+
$model = Mage::getModel('sponsorship/sponsorship');
|
86 |
+
$model->setData($data)
|
87 |
+
->setId($this->getRequest()->getParam('id'));
|
88 |
+
|
89 |
+
try {
|
90 |
+
$model->save();
|
91 |
+
Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('sponsorship')->__('Invitation was successfully saved'));
|
92 |
+
Mage::getSingleton('adminhtml/session')->setFormData(false);
|
93 |
+
|
94 |
+
if ($this->getRequest()->getParam('back')) {
|
95 |
+
$this->_redirect('*/*/edit', array('id' => $model->getId()));
|
96 |
+
return;
|
97 |
+
}
|
98 |
+
$this->_redirect('*/*/');
|
99 |
+
return;
|
100 |
+
} catch (Exception $e) {
|
101 |
+
Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
|
102 |
+
Mage::getSingleton('adminhtml/session')->setFormData($data);
|
103 |
+
$this->_redirect('*/*/edit', array('id' => $this->getRequest()->getParam('id')));
|
104 |
+
return;
|
105 |
+
}
|
106 |
+
}
|
107 |
+
Mage::getSingleton('adminhtml/session')->addError(Mage::helper('sponsorship')->__('Unable to find invitation to save'));
|
108 |
+
$this->_redirect('*/*/');
|
109 |
+
}
|
110 |
+
|
111 |
+
public function exportCsvAction()
|
112 |
+
{
|
113 |
+
$fileName = 'sponsorship.csv';
|
114 |
+
$content = $this->getLayout()->createBlock('sponsorship/adminhtml_sponsorship_grid')
|
115 |
+
->getCsv();
|
116 |
+
|
117 |
+
$this->_sendUploadResponse($fileName, $content);
|
118 |
+
}
|
119 |
+
|
120 |
+
public function exportXmlAction()
|
121 |
+
{
|
122 |
+
$fileName = 'sponsorship.xml';
|
123 |
+
$content = $this->getLayout()->createBlock('sponsorship/adminhtml_sponsorship_grid')
|
124 |
+
->getXml();
|
125 |
+
|
126 |
+
$this->_sendUploadResponse($fileName, $content);
|
127 |
+
}
|
128 |
+
|
129 |
+
protected function _sendUploadResponse($fileName, $content, $contentType='application/octet-stream')
|
130 |
+
{
|
131 |
+
$response = $this->getResponse();
|
132 |
+
$response->setHeader('HTTP/1.1 200 OK','');
|
133 |
+
$response->setHeader('Pragma', 'public', true);
|
134 |
+
$response->setHeader('Cache-Control', 'must-revalidate, post-check=0, pre-check=0', true);
|
135 |
+
$response->setHeader('Content-Disposition', 'attachment; filename='.$fileName);
|
136 |
+
$response->setHeader('Last-Modified', date('r'));
|
137 |
+
$response->setHeader('Accept-Ranges', 'bytes');
|
138 |
+
$response->setHeader('Content-Length', strlen($content));
|
139 |
+
$response->setHeader('Content-type', $contentType);
|
140 |
+
$response->setBody($content);
|
141 |
+
$response->sendResponse();
|
142 |
+
die;
|
143 |
+
}
|
144 |
+
}
|
app/code/community/Auguria/Sponsorship/controllers/BoostController.php
ADDED
@@ -0,0 +1,78 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* @category Auguria
|
4 |
+
* @package Auguria_Sponsorship
|
5 |
+
* @author Auguria
|
6 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
7 |
+
*/
|
8 |
+
class Auguria_Sponsorship_BoostController extends Mage_Core_Controller_Front_Action
|
9 |
+
{
|
10 |
+
public function preDispatch()
|
11 |
+
{
|
12 |
+
parent::preDispatch();
|
13 |
+
if (!Mage::getSingleton('customer/session')->isLoggedIn()) {
|
14 |
+
$this->_redirectUrl(Mage::helper('customer')->getAccountUrl());
|
15 |
+
}
|
16 |
+
}
|
17 |
+
|
18 |
+
public function indexAction()
|
19 |
+
{
|
20 |
+
$this->loadLayout();
|
21 |
+
$this->getLayout()->getBlock('boost');
|
22 |
+
$this->_initLayoutMessages('customer/session');
|
23 |
+
$this->_initLayoutMessages('catalog/session');
|
24 |
+
$this->renderLayout();
|
25 |
+
}
|
26 |
+
|
27 |
+
public function postAction()
|
28 |
+
{
|
29 |
+
$post = $this->getRequest()->getPost();
|
30 |
+
if ( $post )
|
31 |
+
{
|
32 |
+
$translate = Mage::getSingleton('core/translate');
|
33 |
+
$translate->setTranslateInline(false);
|
34 |
+
$mail = Mage::helper('sponsorship/mail');
|
35 |
+
$mails = $mail->processMail($post);
|
36 |
+
$validation = $mail->validateMail($mails);
|
37 |
+
|
38 |
+
|
39 |
+
if ($validation == true)
|
40 |
+
{
|
41 |
+
$isCustomer = $mail->recipientMailIsCustomer($mails[0]["recipient_email"]);
|
42 |
+
if ($isCustomer == true)
|
43 |
+
{
|
44 |
+
Mage::getSingleton('customer/session')->addError($this->__("%s is already an email to our customers",$mails[0]["recipient_email"]));
|
45 |
+
$this->_redirect("*/sponsorpoints/");
|
46 |
+
}
|
47 |
+
else
|
48 |
+
{
|
49 |
+
if ($mail->sendMail($mails[0]))
|
50 |
+
{
|
51 |
+
Mage::getSingleton('customer/session')->addSuccess(Mage::helper('sponsorship')->__("Your email has been successfully sent."));
|
52 |
+
if (!$mail->saveMail($mails[0]))
|
53 |
+
{
|
54 |
+
Mage::getSingleton('customer/session')->addError($this->__("But it could not be saved."));
|
55 |
+
}
|
56 |
+
$this->_redirect("*/sponsorpoints/");
|
57 |
+
}
|
58 |
+
else
|
59 |
+
{
|
60 |
+
//Mage::getSingleton('customer/session')->addError($this->__("Une erreur est survenue, le mail destiné à %s n'a pas pu être délivré.",$recipient));
|
61 |
+
Mage::getSingleton('customer/session')->addError($this->__("Your mail has not been sent, please try again later."));
|
62 |
+
$this->_redirect("*/*/",Array("sponsorship_id"=>$post["sponsorship_id"]));
|
63 |
+
}
|
64 |
+
}
|
65 |
+
}
|
66 |
+
else
|
67 |
+
{
|
68 |
+
Mage::getSingleton('customer/session')->addError($this->__("Please check the form fields."));
|
69 |
+
$this->_redirect("*/*/",Array("sponsorship_id"=>$post["sponsorship_id"]));
|
70 |
+
}
|
71 |
+
$translate->setTranslateInline(true);
|
72 |
+
}
|
73 |
+
else
|
74 |
+
{
|
75 |
+
$this->_redirect("*/sponsorpoints/");
|
76 |
+
}
|
77 |
+
}
|
78 |
+
}
|
app/code/community/Auguria/Sponsorship/controllers/Customer/AccountController.php
ADDED
@@ -0,0 +1,222 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* @category Auguria
|
4 |
+
* @package Auguria_Sponsorship
|
5 |
+
* @author Auguria
|
6 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
7 |
+
*/
|
8 |
+
require_once 'Mage/Customer/controllers/AccountController.php';
|
9 |
+
class Auguria_Sponsorship_Customer_AccountController extends Mage_Customer_AccountController
|
10 |
+
{
|
11 |
+
|
12 |
+
|
13 |
+
public function createPostAction()
|
14 |
+
{
|
15 |
+
if ($this->_getSession()->isLoggedIn()) {
|
16 |
+
$this->_redirect('*/*/');
|
17 |
+
return;
|
18 |
+
}
|
19 |
+
if ($this->getRequest()->isPost()) {
|
20 |
+
$errors = array();
|
21 |
+
|
22 |
+
if (!$customer = Mage::registry('current_customer')) {
|
23 |
+
$customer = Mage::getModel('customer/customer')->setId(null);
|
24 |
+
}
|
25 |
+
|
26 |
+
foreach (Mage::getConfig()->getFieldset('customer_account') as $code=>$node) {
|
27 |
+
if ($node->is('create') && ($value = $this->getRequest()->getParam($code)) !== null) {
|
28 |
+
$customer->setData($code, $value);
|
29 |
+
}
|
30 |
+
}
|
31 |
+
|
32 |
+
if ($this->getRequest()->getParam('is_subscribed', false)) {
|
33 |
+
$customer->setIsSubscribed(1);
|
34 |
+
}
|
35 |
+
|
36 |
+
/**
|
37 |
+
* Initialize customer group id
|
38 |
+
*/
|
39 |
+
$customer->getGroupId();
|
40 |
+
|
41 |
+
if ($this->getRequest()->getPost('create_address')) {
|
42 |
+
$address = Mage::getModel('customer/address')
|
43 |
+
->setData($this->getRequest()->getPost())
|
44 |
+
->setIsDefaultBilling($this->getRequest()->getParam('default_billing', false))
|
45 |
+
->setIsDefaultShipping($this->getRequest()->getParam('default_shipping', false))
|
46 |
+
->setId(null);
|
47 |
+
$customer->addAddress($address);
|
48 |
+
|
49 |
+
$errors = $address->validate();
|
50 |
+
if (!is_array($errors)) {
|
51 |
+
$errors = array();
|
52 |
+
}
|
53 |
+
}
|
54 |
+
//Début modification createPostAction()
|
55 |
+
if ($sponsorId = mage::helper("sponsorship/data")->searchSponsorId($customer->getEmail())) {
|
56 |
+
$customer->setData('sponsor',$sponsorId);
|
57 |
+
$cookie = new Mage_Core_Model_Cookie;
|
58 |
+
if ($cookie->get('sponsorship_id')) {
|
59 |
+
$cookie->delete('sponsorship_id');
|
60 |
+
$cookie->delete('sponsorship_email');
|
61 |
+
$cookie->delete('sponsorship_firstname');
|
62 |
+
$cookie->delete('sponsorship_lastname');
|
63 |
+
}
|
64 |
+
}
|
65 |
+
|
66 |
+
//Fin modification createPostAction()
|
67 |
+
|
68 |
+
try {
|
69 |
+
$validationCustomer = $customer->validate();
|
70 |
+
if (is_array($validationCustomer)) {
|
71 |
+
$errors = array_merge($validationCustomer, $errors);
|
72 |
+
}
|
73 |
+
$validationResult = count($errors) == 0;
|
74 |
+
|
75 |
+
if (true === $validationResult) {
|
76 |
+
$customer->save();
|
77 |
+
|
78 |
+
if ($customer->isConfirmationRequired()) {
|
79 |
+
$customer->sendNewAccountEmail('confirmation', $this->_getSession()->getBeforeAuthUrl());
|
80 |
+
$this->_getSession()->addSuccess($this->__('Account confirmation is required. Please, check your e-mail for confirmation link. To resend confirmation email please <a href="%s">click here</a>.',
|
81 |
+
Mage::helper('customer')->getEmailConfirmationUrl($customer->getEmail())
|
82 |
+
));
|
83 |
+
$this->_redirectSuccess(Mage::getUrl('*/*/index', array('_secure'=>true)));
|
84 |
+
return;
|
85 |
+
}
|
86 |
+
else {
|
87 |
+
$this->_getSession()->setCustomerAsLoggedIn($customer);
|
88 |
+
$url = $this->_welcomeCustomer($customer);
|
89 |
+
$this->_redirectSuccess($url);
|
90 |
+
return;
|
91 |
+
}
|
92 |
+
} else {
|
93 |
+
$this->_getSession()->setCustomerFormData($this->getRequest()->getPost());
|
94 |
+
if (is_array($errors)) {
|
95 |
+
foreach ($errors as $errorMessage) {
|
96 |
+
$this->_getSession()->addError($errorMessage);
|
97 |
+
}
|
98 |
+
}
|
99 |
+
else {
|
100 |
+
$this->_getSession()->addError($this->__('Invalid customer data'));
|
101 |
+
}
|
102 |
+
}
|
103 |
+
}
|
104 |
+
catch (Mage_Core_Exception $e) {
|
105 |
+
$this->_getSession()->addError($e->getMessage())
|
106 |
+
->setCustomerFormData($this->getRequest()->getPost());
|
107 |
+
}
|
108 |
+
catch (Exception $e) {
|
109 |
+
$this->_getSession()->setCustomerFormData($this->getRequest()->getPost())
|
110 |
+
->addException($e, $this->__('Can\'t save customer'));
|
111 |
+
}
|
112 |
+
}
|
113 |
+
|
114 |
+
$this->_redirectError(Mage::getUrl('*/*/create', array('_secure'=>true)));
|
115 |
+
}
|
116 |
+
|
117 |
+
public function editPostAction()
|
118 |
+
{
|
119 |
+
if (!$this->_validateFormKey()) {
|
120 |
+
return $this->_redirect('*/*/edit');
|
121 |
+
}
|
122 |
+
|
123 |
+
if ($this->getRequest()->isPost()) {
|
124 |
+
$customer = Mage::getModel('customer/customer')
|
125 |
+
->setId($this->_getSession()->getCustomerId())
|
126 |
+
->setWebsiteId($this->_getSession()->getCustomer()->getWebsiteId());
|
127 |
+
|
128 |
+
$fields = Mage::getConfig()->getFieldset('customer_account');
|
129 |
+
foreach ($fields as $code=>$node) {
|
130 |
+
if ($node->is('update') && ($value = $this->getRequest()->getParam($code)) !== null) {
|
131 |
+
$customer->setData($code, $value);
|
132 |
+
}
|
133 |
+
}
|
134 |
+
|
135 |
+
/*
|
136 |
+
* Ajout des champs iban et siret
|
137 |
+
*/
|
138 |
+
|
139 |
+
if ($this->getRequest()->getParam('iban')) {
|
140 |
+
$customerIban = $this->getRequest()->getPost('iban');
|
141 |
+
$customerIban = str_replace(CHR(32),"",$customerIban);
|
142 |
+
$customerIban = str_replace("-","",$customerIban);
|
143 |
+
$customer->setData('iban', $customerIban);
|
144 |
+
}
|
145 |
+
|
146 |
+
if ($this->getRequest()->getParam('siret')) {
|
147 |
+
$customerSiret = $this->getRequest()->getPost('siret');
|
148 |
+
$customerSiret = str_replace(CHR(32),"",$customerSiret);
|
149 |
+
$customerSiret = str_replace("-","",$customerSiret);
|
150 |
+
$customer->setData('siret', $customerSiret);
|
151 |
+
}
|
152 |
+
|
153 |
+
$errors = $customer->validate();
|
154 |
+
if (!is_array($errors)) {
|
155 |
+
$errors = array();
|
156 |
+
}
|
157 |
+
|
158 |
+
/**
|
159 |
+
* we would like to preserver the existing group id
|
160 |
+
*/
|
161 |
+
if ($this->_getSession()->getCustomerGroupId()) {
|
162 |
+
$customer->setGroupId($this->_getSession()->getCustomerGroupId());
|
163 |
+
}
|
164 |
+
if ($this->getRequest()->getParam('change_password')) {
|
165 |
+
$currPass = $this->getRequest()->getPost('current_password');
|
166 |
+
$newPass = $this->getRequest()->getPost('password');
|
167 |
+
$confPass = $this->getRequest()->getPost('confirmation');
|
168 |
+
|
169 |
+
if (empty($currPass) || empty($newPass) || empty($confPass)) {
|
170 |
+
$errors[] = $this->__('Password fields can\'t be empty.');
|
171 |
+
}
|
172 |
+
|
173 |
+
if ($newPass != $confPass) {
|
174 |
+
$errors[] = $this->__('Please make sure your passwords match.');
|
175 |
+
}
|
176 |
+
|
177 |
+
$oldPass = $this->_getSession()->getCustomer()->getPasswordHash();
|
178 |
+
if (strpos($oldPass, ':')) {
|
179 |
+
list($_salt, $salt) = explode(':', $oldPass);
|
180 |
+
} else {
|
181 |
+
$salt = false;
|
182 |
+
}
|
183 |
+
|
184 |
+
if ($customer->hashPassword($currPass, $salt) == $oldPass) {
|
185 |
+
$customer->setPassword($newPass);
|
186 |
+
} else {
|
187 |
+
$errors[] = $this->__('Invalid current password');
|
188 |
+
}
|
189 |
+
}
|
190 |
+
|
191 |
+
if (!empty($errors)) {
|
192 |
+
$this->_getSession()->setCustomerFormData($this->getRequest()->getPost());
|
193 |
+
foreach ($errors as $message) {
|
194 |
+
$this->_getSession()->addError($message);
|
195 |
+
}
|
196 |
+
$this->_redirect('*/*/edit');
|
197 |
+
return $this;
|
198 |
+
}
|
199 |
+
|
200 |
+
|
201 |
+
try {
|
202 |
+
$customer->save();
|
203 |
+
$this->_getSession()->setCustomer($customer)
|
204 |
+
->addSuccess($this->__('Account information was successfully saved'));
|
205 |
+
|
206 |
+
$this->_redirect('customer/account');
|
207 |
+
return;
|
208 |
+
}
|
209 |
+
catch (Mage_Core_Exception $e) {
|
210 |
+
$this->_getSession()->setCustomerFormData($this->getRequest()->getPost())
|
211 |
+
->addError($e->getMessage());
|
212 |
+
}
|
213 |
+
catch (Exception $e) {
|
214 |
+
$this->_getSession()->setCustomerFormData($this->getRequest()->getPost())
|
215 |
+
->addException($e, $this->__('Can\'t save customer'));
|
216 |
+
}
|
217 |
+
}
|
218 |
+
|
219 |
+
$this->_redirect('*/*/edit');
|
220 |
+
}
|
221 |
+
}
|
222 |
+
?>
|
app/code/community/Auguria/Sponsorship/controllers/FidelitypointsController.php
ADDED
@@ -0,0 +1,352 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* @category Auguria
|
4 |
+
* @package Auguria_Sponsorship
|
5 |
+
* @author Auguria
|
6 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
7 |
+
*/
|
8 |
+
class Auguria_Sponsorship_FidelitypointsController extends Mage_Core_Controller_Front_Action
|
9 |
+
{
|
10 |
+
public function preDispatch()
|
11 |
+
{
|
12 |
+
parent::preDispatch();
|
13 |
+
if (!Mage::getSingleton('customer/session')->isLoggedIn()) {
|
14 |
+
$this->_redirectUrl(Mage::helper('customer')->getAccountUrl());
|
15 |
+
}
|
16 |
+
}
|
17 |
+
|
18 |
+
public function indexAction()
|
19 |
+
{
|
20 |
+
$this->loadLayout();
|
21 |
+
$this->getLayout()->getBlock('customer');
|
22 |
+
$this->_initLayoutMessages('customer/session');
|
23 |
+
$this->_initLayoutMessages('catalog/session');
|
24 |
+
$this->renderLayout();
|
25 |
+
}
|
26 |
+
|
27 |
+
public function changeAction()
|
28 |
+
{
|
29 |
+
$module = $this->getRequest()->getParam('module');
|
30 |
+
$type = $this->getRequest()->getParam('type');
|
31 |
+
$resultValidate = $this->validateChange($module, $type);
|
32 |
+
if ($resultValidate == 'valide' )
|
33 |
+
{
|
34 |
+
$this->loadLayout();
|
35 |
+
$this->getLayout()
|
36 |
+
->getBlock('customer');
|
37 |
+
$this->_initLayoutMessages('customer/session');
|
38 |
+
$this->_initLayoutMessages('catalog/session');
|
39 |
+
$this->renderLayout();
|
40 |
+
}
|
41 |
+
elseif ($resultValidate == 'inactif' )
|
42 |
+
{
|
43 |
+
$this->_redirect('*/*/');
|
44 |
+
}
|
45 |
+
elseif ($resultValidate == 'account' )
|
46 |
+
{
|
47 |
+
$this->_redirectUrl(Mage::helper('customer')->getAccountUrl().'edit');
|
48 |
+
}
|
49 |
+
}
|
50 |
+
|
51 |
+
public function saveAction()
|
52 |
+
{
|
53 |
+
if (!$this->_validateFormKey()) {
|
54 |
+
return $this->_redirect('*/*');
|
55 |
+
}
|
56 |
+
else
|
57 |
+
{
|
58 |
+
$module = $this->getRequest()->getPost('module');
|
59 |
+
$type = $this->getRequest()->getPost('type');
|
60 |
+
$points = $this->getRequest()->getPost('points');
|
61 |
+
$resultValidate = $this->validateChange($module, $type, $points);
|
62 |
+
$value = $this->getValue($points, $type, $module);
|
63 |
+
|
64 |
+
if ($resultValidate == 'valide' )
|
65 |
+
{
|
66 |
+
try
|
67 |
+
{
|
68 |
+
$customerId = Mage::getSingleton('customer/session')->getId();
|
69 |
+
$customer = Mage::getModel("customer/customer")->load($customerId);
|
70 |
+
|
71 |
+
//récupération des points clients
|
72 |
+
$getdatapoints = 'get'.ucfirst($module).'Points';
|
73 |
+
$cPoints = $customer->$getdatapoints();
|
74 |
+
//décrémentation des points du client
|
75 |
+
$setdatapoints = 'set'.ucfirst($module).'Points';
|
76 |
+
$newPoints = $cPoints - $points;
|
77 |
+
$customer->$setdatapoints($newPoints);
|
78 |
+
$customer->save();
|
79 |
+
|
80 |
+
$dateTime = Mage::getModel('core/date')->date();
|
81 |
+
$statut = "waiting";
|
82 |
+
|
83 |
+
//inscription de l'opération dans la table des echanges
|
84 |
+
$echange = Mage::getModel('sponsorship/change');
|
85 |
+
$row = array(
|
86 |
+
'customer_id' => $customerId,
|
87 |
+
'type' => $type,
|
88 |
+
'module' => $module,
|
89 |
+
'statut' => $statut,
|
90 |
+
'datetime' => $dateTime,
|
91 |
+
'points' => $points,
|
92 |
+
'value' => $value
|
93 |
+
);
|
94 |
+
$echange->setData($row);
|
95 |
+
$echange->save();
|
96 |
+
$echangeId = $echange->getId();
|
97 |
+
|
98 |
+
//inscription dans les logs
|
99 |
+
$log = Mage::getModel('sponsorship/'.$module.'log');
|
100 |
+
if ($module == 'fidelity')
|
101 |
+
{
|
102 |
+
$data = array(
|
103 |
+
'customer_id' => $customerId,
|
104 |
+
'record_id' => $echangeId,
|
105 |
+
'record_type' => $type,
|
106 |
+
'datetime' => $dateTime,
|
107 |
+
'points' => -$points
|
108 |
+
);
|
109 |
+
}
|
110 |
+
elseif ($module == 'sponsor')
|
111 |
+
{
|
112 |
+
$data = array(
|
113 |
+
'godson_id' => $customerId,
|
114 |
+
'sponsor_id' => $customerId,
|
115 |
+
'record_id' => $echangeId,
|
116 |
+
'record_type' => $type,
|
117 |
+
'datetime' => $dateTime,
|
118 |
+
'points' => -$points
|
119 |
+
);
|
120 |
+
}
|
121 |
+
$log->setData($data);
|
122 |
+
$log->save();
|
123 |
+
|
124 |
+
Mage::getSingleton('customer/session')->addSuccess(Mage::helper('sponsorship')->__('Your request has been submitted, you will soon receive an email confirmation.'));
|
125 |
+
$this->_redirect('*/*/');
|
126 |
+
}
|
127 |
+
|
128 |
+
catch (Exception $e) {
|
129 |
+
Mage::log($e->getMessage());
|
130 |
+
Mage::getSingleton('customer/session')->addError(Mage::helper('sponsorship')->__("An error occurred while saving your request."));
|
131 |
+
$this->_redirect('*/*/');
|
132 |
+
}
|
133 |
+
}
|
134 |
+
elseif ($resultValidate == 'inactif' )
|
135 |
+
{
|
136 |
+
$this->_redirect('*/*/');
|
137 |
+
}
|
138 |
+
elseif ($resultValidate == 'account' )
|
139 |
+
{
|
140 |
+
$this->_redirectUrl(Mage::helper('customer')->getAccountUrl().'edit');
|
141 |
+
}
|
142 |
+
elseif ($resultValidate == 'points' )
|
143 |
+
{
|
144 |
+
$this->_redirect('*/*/change', Array('module'=>$module, 'type'=>$type));
|
145 |
+
}
|
146 |
+
elseif ($resultValidate == 'mail' )
|
147 |
+
{
|
148 |
+
Mage::getSingleton('customer/session')->addError(Mage::helper('sponsorship')->__("An error occurred while sending mail."));
|
149 |
+
$this->_redirect('*/*/change', Array('module'=>$module, 'type'=>$type));
|
150 |
+
}
|
151 |
+
}
|
152 |
+
}
|
153 |
+
|
154 |
+
protected function validateChange($module, $type, $points='')
|
155 |
+
{
|
156 |
+
$options = Mage::getBlockSingleton('sponsorship/customer_account_pointsDetail');
|
157 |
+
$session = Mage::getSingleton('customer/session');
|
158 |
+
|
159 |
+
$Module = ucfirst($module);
|
160 |
+
$Type = ucfirst($type);
|
161 |
+
|
162 |
+
$changeEnabled = 'get'.$Module.$Type.'Config';
|
163 |
+
$moduleEnabled = 'get'.$Module.'EnabledConfig';
|
164 |
+
|
165 |
+
if (($options->$moduleEnabled()==1 && $options->$changeEnabled()==1))
|
166 |
+
{
|
167 |
+
$validate = 'validate'.$Type;
|
168 |
+
return $this->$validate($module,$points);
|
169 |
+
}
|
170 |
+
else
|
171 |
+
{
|
172 |
+
$session->addError(Mage::helper('sponsorship')->__('The exchange of %s points in %s is disabled.',$this->__($module),$this->__($type)));
|
173 |
+
return 'inactif';
|
174 |
+
}
|
175 |
+
}
|
176 |
+
protected function validateCoupon ($module, $points='')
|
177 |
+
{
|
178 |
+
$validate = 'valide';
|
179 |
+
$customerId = Mage::getSingleton('customer/session')->getId();
|
180 |
+
$customer = Mage::getModel("customer/customer")->load($customerId);
|
181 |
+
|
182 |
+
//vérification que les points à changer sonts inférieurs aux points du client
|
183 |
+
if ($points != '')
|
184 |
+
{
|
185 |
+
$data = 'get'.ucfirst($module).'Points';
|
186 |
+
$cPoints = $customer->$data();
|
187 |
+
if ($points>$cPoints)
|
188 |
+
{
|
189 |
+
Mage::getSingleton('customer/session')->addError(Mage::helper('sponsorship')->__("You do not have as many points."));
|
190 |
+
$validate = 'points';
|
191 |
+
}
|
192 |
+
else
|
193 |
+
{
|
194 |
+
//création de la règle panier---------------------------------------------------
|
195 |
+
$options = Mage::getBlockSingleton('sponsorship/customer_account_pointsDetail');
|
196 |
+
$srModel = Mage::getModel('salesrule/rule');
|
197 |
+
$date = now();
|
198 |
+
$chars = array("-", ":", " ");
|
199 |
+
$simpledate = str_replace($chars, "", $date);
|
200 |
+
$couponCode = $customerId."-".$points.$simpledate;//idClient-date-module-somme
|
201 |
+
$name = $this->__("%s points exchange for customer (%s)", $this->__($module), $customerId);
|
202 |
+
$description = $name;
|
203 |
+
$customerGroupId = $customer->getGroupId();
|
204 |
+
$discountAmount = $this->getValue ($points, "coupon", $module);
|
205 |
+
$websiteId = $customer->getWebsiteId();
|
206 |
+
$data = array
|
207 |
+
(
|
208 |
+
"name" => $name,
|
209 |
+
"description" => $description,
|
210 |
+
"from_date" => $date,
|
211 |
+
"coupon_code" => $couponCode,
|
212 |
+
"uses_per_coupon" => 1,
|
213 |
+
//"uses_per_customer" => 1,
|
214 |
+
"customer_group_ids" => Array(0 => $customerGroupId),//get customer group
|
215 |
+
"is_active" => 1,
|
216 |
+
"conditions_serialized" => 'a:7:{s:4:"type";s:32:"salesrule/rule_condition_combine";s:9:"attribute";N;s:8:"operator";N;s:5:"value";s:1:"1";s:18:"is_value_processed";N;s:10:"aggregator";s:3:"all";s:10:"conditions";a:1:{i:0;a:5:{s:4:"type";s:32:"salesrule/rule_condition_address";s:9:"attribute";s:9:"total_qty";s:8:"operator";s:1:">";s:5:"value";s:1:"0";s:18:"is_value_processed";b:0;}}}',
|
217 |
+
"actions_serialized" => 'a:6:{s:4:"type";s:40:"salesrule/rule_condition_product_combine";s:9:"attribute";N;s:8:"operator";N;s:5:"value";s:1:"1";s:18:"is_value_processed";N;s:10:"aggregator";s:3:"all";}',
|
218 |
+
"stop_rules_processing" => 0,
|
219 |
+
"is_advanced" => 1,
|
220 |
+
"sort_order" => 0,
|
221 |
+
"simple_action" => "by_fixed",
|
222 |
+
"discount_amount" => $discountAmount,
|
223 |
+
"discount_qty" => 1.0000,
|
224 |
+
"discount_step" => 0,
|
225 |
+
"simple_free_shipping" => 0,
|
226 |
+
"times_used" => 0,
|
227 |
+
"is_rss" => 1,
|
228 |
+
"website_ids" => Array(0 => $websiteId)//get website id
|
229 |
+
);
|
230 |
+
$srModel->setData($data);
|
231 |
+
$srModel->save();
|
232 |
+
//envoi du mail--------------------------------------------------------------
|
233 |
+
//construction du message
|
234 |
+
$mailTemplate = Mage::getModel('sponsorship/Core_Email_Template');
|
235 |
+
|
236 |
+
$sender_name = Mage::getStoreConfig('trans_email/ident_sales/name');
|
237 |
+
$sender_email = Mage::getStoreConfig('trans_email/ident_sales/email');
|
238 |
+
|
239 |
+
$subject = $this->__('%s vouchers points exchange', Mage::helper('sponsorship/mail')->getStoreName());
|
240 |
+
|
241 |
+
$sender = array("name"=>$sender_name, "email"=>$sender_email);
|
242 |
+
$recipient_email = $customer->getData('email');
|
243 |
+
|
244 |
+
$postObject = new Varien_Object();
|
245 |
+
$postObject->setData(Array ("sender_name" => $sender_name,
|
246 |
+
"sender_email" => $sender_email,
|
247 |
+
"recipient_firstname" => $customer->getFirstname(),
|
248 |
+
"recipient_lastname" => $customer->getLastname(),
|
249 |
+
"discount_amount" => $discountAmount,
|
250 |
+
"subject" => $subject,
|
251 |
+
"coupon_code" => $couponCode,
|
252 |
+
"store_name" => Mage::helper('sponsorship/mail')->getStoreName()
|
253 |
+
));
|
254 |
+
|
255 |
+
$mailTemplate->setDesignConfig(array('area' => 'fronted'))
|
256 |
+
->setReplyTo($sender_email)
|
257 |
+
//->setReturnPath($sender_email)
|
258 |
+
->sendTransactional(
|
259 |
+
"sponsorship_email_coupon",
|
260 |
+
$sender,
|
261 |
+
$recipient_email,
|
262 |
+
$customer->getFirstname().' '.$customer->getLastname(),
|
263 |
+
array('data' => $postObject)
|
264 |
+
);
|
265 |
+
if (!$mailTemplate->getSentSuccess())
|
266 |
+
{
|
267 |
+
$validate = "mail";
|
268 |
+
}
|
269 |
+
|
270 |
+
}
|
271 |
+
}
|
272 |
+
return $validate;
|
273 |
+
}
|
274 |
+
|
275 |
+
protected function validateGift ($module, $points='')
|
276 |
+
{
|
277 |
+
return 'valide';
|
278 |
+
}
|
279 |
+
|
280 |
+
protected function validateCash ($module, $points=0)
|
281 |
+
{
|
282 |
+
$validate = 'valide';
|
283 |
+
$customerId = Mage::getSingleton('customer/session')->getId();
|
284 |
+
$maxCash = "";
|
285 |
+
$options = Mage::getBlockSingleton('sponsorship/customer_account_pointsDetail');
|
286 |
+
|
287 |
+
//Validation qu'un Iban est renseigné
|
288 |
+
$customer = Mage::getModel("customer/customer")->load($customerId);
|
289 |
+
|
290 |
+
if (!$customer->getIban()) {
|
291 |
+
Mage::getSingleton('customer/session')->addError(Mage::helper('sponsorship')->__('To change your points into cash, you must indicate your IBAN.'));
|
292 |
+
$validate = 'account';
|
293 |
+
}
|
294 |
+
|
295 |
+
//Validation qu'un Siret est renseigné si le max de cash pour un particulier est atteint
|
296 |
+
if ($module=='sponsor') {
|
297 |
+
$maxCash = $options->getSponsorMaxCashConfig ();
|
298 |
+
$timeMaxCash = $options->getSponsorTimeMaxCashConfig ();
|
299 |
+
}
|
300 |
+
elseif ($module=='fidelity') {
|
301 |
+
$maxCash = $options->getFidelityMaxCashConfig ();
|
302 |
+
$timeMaxCash = $options->getFidelityTimeMaxCashConfig ();
|
303 |
+
}
|
304 |
+
$resource = Mage::getSingleton('core/resource');
|
305 |
+
$read = $resource->getConnection('core_read');
|
306 |
+
$select = $read->select()
|
307 |
+
->from($resource->getTableName('sponsorship/change'), 'SUM(points)')
|
308 |
+
->where('customer_id=?', $customerId)
|
309 |
+
->where('module=?', $module)
|
310 |
+
->where('type=?', 'cash')
|
311 |
+
->where('statut!=?', 'canceled')
|
312 |
+
->where('TO_DAYS(NOW()) - TO_DAYS(datetime) <=?', $timeMaxCash);
|
313 |
+
|
314 |
+
$cashPoints = $read->fetchOne($select);
|
315 |
+
|
316 |
+
//Addition des points déjà changés avec les points demandés
|
317 |
+
$cashPoints = $points+$cashPoints;
|
318 |
+
|
319 |
+
//vérification que le total ne dépasse pas le maximum autorisé
|
320 |
+
if ($cashPoints >= $maxCash) {
|
321 |
+
if (!$customer->getSiret())
|
322 |
+
{
|
323 |
+
Mage::getSingleton('customer/session')->addError(Mage::helper('sponsorship')->__('To change more cash, you must specify a company number.'));
|
324 |
+
$validate = 'account';
|
325 |
+
}
|
326 |
+
}
|
327 |
+
|
328 |
+
//vérification que les points à changer sonts inférieurs aux points du client
|
329 |
+
if ($points != '')
|
330 |
+
{
|
331 |
+
$data = 'get'.ucfirst($module).'Points';
|
332 |
+
$cPoints = $customer->$data();
|
333 |
+
if ($points>$cPoints)
|
334 |
+
{
|
335 |
+
Mage::getSingleton('customer/session')->addError(Mage::helper('sponsorship')->__("You do not have as many points."));
|
336 |
+
$validate = 'points';
|
337 |
+
}
|
338 |
+
}
|
339 |
+
return $validate;
|
340 |
+
}
|
341 |
+
|
342 |
+
protected function getValue ($points, $type, $module)
|
343 |
+
{
|
344 |
+
//if ($type == 'cash')
|
345 |
+
//recuperation du taux de conversion
|
346 |
+
$options = Mage::getBlockSingleton('sponsorship/customer_account_pointsDetail');
|
347 |
+
$getPointsToCash = 'get'.ucfirst($module).'PointsToCashConfig';
|
348 |
+
$PointsToCash = $options->$getPointsToCash();
|
349 |
+
$value = round($points*$PointsToCash,2);
|
350 |
+
return $value;
|
351 |
+
}
|
352 |
+
}
|
app/code/community/Auguria/Sponsorship/controllers/IndexController.php
ADDED
@@ -0,0 +1,108 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* @category Auguria
|
4 |
+
* @package Auguria_Sponsorship
|
5 |
+
* @author Auguria
|
6 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
7 |
+
*/
|
8 |
+
class Auguria_Sponsorship_IndexController extends Mage_Core_Controller_Front_Action
|
9 |
+
{
|
10 |
+
public function preDispatch()
|
11 |
+
{
|
12 |
+
parent::preDispatch();
|
13 |
+
//verification que le module de parrainage est activé
|
14 |
+
if( !Mage::getStoreConfig('sponsorship/sponsor/sponsor_enabled')) {
|
15 |
+
$this->_redirect('');
|
16 |
+
}
|
17 |
+
//verification que l'utilisateur est logué
|
18 |
+
elseif (!Mage::getSingleton('customer/session')->isLoggedIn()) {
|
19 |
+
$this->_redirectUrl(Mage::helper('customer')->getAccountUrl());
|
20 |
+
}
|
21 |
+
//verification que l'envoie de mail est autorisé sans commande
|
22 |
+
elseif (!Mage::getStoreConfig('sponsorship/sponsor/sponsor_optional_order') &&
|
23 |
+
!Mage::helper('sponsorship/data')->haveOrder()) {
|
24 |
+
//vérification qu'une commande a été passée
|
25 |
+
if (!Mage::helper('sponsorship/data')->haveOrder()) {
|
26 |
+
$this->_redirecturl(Mage::helper('customer')->getAccountUrl());
|
27 |
+
}
|
28 |
+
}
|
29 |
+
}
|
30 |
+
|
31 |
+
public function indexAction()
|
32 |
+
{
|
33 |
+
$this->loadLayout();
|
34 |
+
$this->getLayout()->getBlock('sponsorship');
|
35 |
+
// ->setFormAction( Mage::getUrl('sponsorship/index/post') );
|
36 |
+
$this->_initLayoutMessages('customer/session');
|
37 |
+
$this->_initLayoutMessages('catalog/session');
|
38 |
+
$this->renderLayout();
|
39 |
+
|
40 |
+
//Ajout d'un message d'erreur si l'envoie de mail n'est pas autorisé sans commande et que le client n'a pas commandé
|
41 |
+
if (!Mage::getStoreConfig('sponsorship/sponsor/sponsor_optional_order')) {
|
42 |
+
if (!Mage::helper('sponsorship/data')->haveOrder()) {
|
43 |
+
Mage::getSingleton('customer/session')->addError(Mage::helper('sponsorship')->__('You must already have purchased to sponsor.'));
|
44 |
+
}
|
45 |
+
}
|
46 |
+
}
|
47 |
+
|
48 |
+
public function postAction()
|
49 |
+
{
|
50 |
+
$post = $this->getRequest()->getPost();
|
51 |
+
if ( $post )
|
52 |
+
{
|
53 |
+
$translate = Mage::getSingleton('core/translate');
|
54 |
+
$translate->setTranslateInline(false);
|
55 |
+
$mail = Mage::helper('sponsorship/mail');
|
56 |
+
$mails = $mail->processMail($post);
|
57 |
+
$validation = $mail->validateMail($mails);
|
58 |
+
$checksend = false;
|
59 |
+
$checksave = false;
|
60 |
+
if ($validation == true)
|
61 |
+
{
|
62 |
+
foreach ($mails as $email)
|
63 |
+
{
|
64 |
+
$isCustomer = $mail->recipientMailIsCustomer($email["recipient_email"]);
|
65 |
+
if ($isCustomer == true)
|
66 |
+
{
|
67 |
+
Mage::getSingleton('customer/session')->addError($this->__("%s is already an email to our customers",$email["recipient_email"]));
|
68 |
+
}
|
69 |
+
else
|
70 |
+
{
|
71 |
+
if ($mail->sendMail($email))
|
72 |
+
{
|
73 |
+
if ($checksend == false)
|
74 |
+
{
|
75 |
+
Mage::getSingleton('customer/session')->addSuccess(Mage::helper('sponsorship')->__("Your email has been successfully sent."));
|
76 |
+
$checksend = true;
|
77 |
+
}
|
78 |
+
if (!$mail->saveMail($email))
|
79 |
+
{
|
80 |
+
if ($checksave == false)
|
81 |
+
{
|
82 |
+
Mage::getSingleton('customer/session')->addError($this->__("But it could not be saved."));
|
83 |
+
$checksave = true;
|
84 |
+
}
|
85 |
+
}
|
86 |
+
}
|
87 |
+
else
|
88 |
+
{
|
89 |
+
Mage::getSingleton('customer/session')->addError($this->__("An error occurred, the mail to %s could not be delivred.",$email["recipient_email"]));
|
90 |
+
}
|
91 |
+
}
|
92 |
+
}
|
93 |
+
}
|
94 |
+
else
|
95 |
+
{
|
96 |
+
Mage::getSingleton('customer/session')->addError($this->__("Please check the form fields."));
|
97 |
+
$this->_redirect("*/*/");
|
98 |
+
}
|
99 |
+
$translate->setTranslateInline(true);
|
100 |
+
$this->_redirect("*/*/");
|
101 |
+
}
|
102 |
+
else
|
103 |
+
{
|
104 |
+
$this->_redirect("*/*/");
|
105 |
+
}
|
106 |
+
}
|
107 |
+
|
108 |
+
}
|
app/code/community/Auguria/Sponsorship/controllers/SponsorController.php
ADDED
@@ -0,0 +1,49 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* @category Auguria
|
4 |
+
* @package Auguria_Sponsorship
|
5 |
+
* @author Auguria
|
6 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
7 |
+
*/
|
8 |
+
class Auguria_Sponsorship_SponsorController extends Mage_Core_Controller_Front_Action
|
9 |
+
{
|
10 |
+
public function preDispatch()
|
11 |
+
{
|
12 |
+
parent::preDispatch();
|
13 |
+
}
|
14 |
+
|
15 |
+
public function indexAction()
|
16 |
+
{
|
17 |
+
/*
|
18 |
+
* Transmission de l'id du parrain + nom + prenom dans l'url
|
19 |
+
* http://www.inkonso.com/index.php/sponsorship/sponsor_id/xxx/nom/xxx/prenom/xxx
|
20 |
+
*/
|
21 |
+
$sponsorId = $this->getRequest()->getParam('sponsor_id');
|
22 |
+
if ($sponsorId!='')
|
23 |
+
{
|
24 |
+
$nom = $this->getRequest()->getParam('nom');
|
25 |
+
$prenom = $this->getRequest()->getParam('prenom');
|
26 |
+
$email = $this->getRequest()->getParam('email');
|
27 |
+
|
28 |
+
//stockage des variables dans la session
|
29 |
+
$session = Mage::getSingleton('core/session');
|
30 |
+
$session->setData('sponsor_id',$sponsorId);
|
31 |
+
$session->setData('firstname',$prenom);
|
32 |
+
$session->setData('lastname',$nom);
|
33 |
+
$session->setData('email',$email);
|
34 |
+
|
35 |
+
//stockage de l'id du parrain dans un cookie
|
36 |
+
|
37 |
+
$sponsorInvitationValidity = Mage::getStoreConfig('sponsorship/sponsor/sponsor_invitation_validity');
|
38 |
+
$period =3600*24*$sponsorInvitationValidity;
|
39 |
+
|
40 |
+
$cookie = new Mage_Core_Model_Cookie;
|
41 |
+
$cookie->set('sponsorship_id', $sponsorId, $period);
|
42 |
+
$cookie->set('sponsorship_firstname', $prenom, $period);
|
43 |
+
$cookie->set('sponsorship_lastname', $nom, $period);
|
44 |
+
$cookie->set('sponsorship_email', $email, $period);
|
45 |
+
}
|
46 |
+
//redirection vers la page d'accueil
|
47 |
+
$this->_redirect('');
|
48 |
+
}
|
49 |
+
}
|
app/code/community/Auguria/Sponsorship/controllers/SponsorpointsController.php
ADDED
@@ -0,0 +1,352 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* @category Auguria
|
4 |
+
* @package Auguria_Sponsorship
|
5 |
+
* @author Auguria
|
6 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
7 |
+
*/
|
8 |
+
class Auguria_Sponsorship_SponsorpointsController extends Mage_Core_Controller_Front_Action
|
9 |
+
{
|
10 |
+
public function preDispatch()
|
11 |
+
{
|
12 |
+
parent::preDispatch();
|
13 |
+
if (!Mage::getSingleton('customer/session')->isLoggedIn()) {
|
14 |
+
$this->_redirectUrl(Mage::helper('customer')->getAccountUrl());
|
15 |
+
}
|
16 |
+
}
|
17 |
+
|
18 |
+
public function indexAction()
|
19 |
+
{
|
20 |
+
$this->loadLayout();
|
21 |
+
$this->getLayout()->getBlock('customer');
|
22 |
+
$this->_initLayoutMessages('customer/session');
|
23 |
+
$this->_initLayoutMessages('catalog/session');
|
24 |
+
$this->renderLayout();
|
25 |
+
}
|
26 |
+
|
27 |
+
public function changeAction()
|
28 |
+
{
|
29 |
+
$module = $this->getRequest()->getParam('module');
|
30 |
+
$type = $this->getRequest()->getParam('type');
|
31 |
+
$resultValidate = $this->validateChange($module, $type);
|
32 |
+
if ($resultValidate == 'valide' )
|
33 |
+
{
|
34 |
+
$this->loadLayout();
|
35 |
+
$this->getLayout()
|
36 |
+
->getBlock('customer');
|
37 |
+
$this->_initLayoutMessages('customer/session');
|
38 |
+
$this->_initLayoutMessages('catalog/session');
|
39 |
+
$this->renderLayout();
|
40 |
+
}
|
41 |
+
elseif ($resultValidate == 'inactif' )
|
42 |
+
{
|
43 |
+
$this->_redirect('*/*/');
|
44 |
+
}
|
45 |
+
elseif ($resultValidate == 'account' )
|
46 |
+
{
|
47 |
+
$this->_redirectUrl(Mage::helper('customer')->getAccountUrl().'edit');
|
48 |
+
}
|
49 |
+
}
|
50 |
+
|
51 |
+
public function saveAction()
|
52 |
+
{
|
53 |
+
if (!$this->_validateFormKey()) {
|
54 |
+
return $this->_redirect('*/*');
|
55 |
+
}
|
56 |
+
else
|
57 |
+
{
|
58 |
+
$module = $this->getRequest()->getPost('module');
|
59 |
+
$type = $this->getRequest()->getPost('type');
|
60 |
+
$points = $this->getRequest()->getPost('points');
|
61 |
+
$resultValidate = $this->validateChange($module, $type, $points);
|
62 |
+
$value = $this->getValue($points, $type, $module);
|
63 |
+
|
64 |
+
if ($resultValidate == 'valide' )
|
65 |
+
{
|
66 |
+
try
|
67 |
+
{
|
68 |
+
$customerId = Mage::getSingleton('customer/session')->getId();
|
69 |
+
$customer = Mage::getModel("customer/customer")->load($customerId);
|
70 |
+
|
71 |
+
//récupération des points clients
|
72 |
+
$getdatapoints = 'get'.ucfirst($module).'Points';
|
73 |
+
$cPoints = $customer->$getdatapoints();
|
74 |
+
//décrémentation des points du client
|
75 |
+
$setdatapoints = 'set'.ucfirst($module).'Points';
|
76 |
+
$newPoints = $cPoints - $points;
|
77 |
+
$customer->$setdatapoints($newPoints);
|
78 |
+
$customer->save();
|
79 |
+
|
80 |
+
$dateTime = Mage::getModel('core/date')->date();
|
81 |
+
$statut = "waiting";
|
82 |
+
|
83 |
+
//inscription de l'opération dans la table des echanges
|
84 |
+
$echange = Mage::getModel('sponsorship/change');
|
85 |
+
$row = array(
|
86 |
+
'customer_id' => $customerId,
|
87 |
+
'type' => $type,
|
88 |
+
'module' => $module,
|
89 |
+
'statut' => $statut,
|
90 |
+
'datetime' => $dateTime,
|
91 |
+
'points' => $points,
|
92 |
+
'value' => $value
|
93 |
+
);
|
94 |
+
$echange->setData($row);
|
95 |
+
$echange->save();
|
96 |
+
$echangeId = $echange->getId();
|
97 |
+
|
98 |
+
//inscription dans les logs
|
99 |
+
$log = Mage::getModel('sponsorship/'.$module.'log');
|
100 |
+
if ($module == 'fidelity')
|
101 |
+
{
|
102 |
+
$data = array(
|
103 |
+
'customer_id' => $customerId,
|
104 |
+
'record_id' => $echangeId,
|
105 |
+
'record_type' => $type,
|
106 |
+
'datetime' => $dateTime,
|
107 |
+
'points' => -$points
|
108 |
+
);
|
109 |
+
}
|
110 |
+
elseif ($module == 'sponsor')
|
111 |
+
{
|
112 |
+
$data = array(
|
113 |
+
'godson_id' => $customerId,
|
114 |
+
'sponsor_id' => $customerId,
|
115 |
+
'record_id' => $echangeId,
|
116 |
+
'record_type' => $type,
|
117 |
+
'datetime' => $dateTime,
|
118 |
+
'points' => -$points
|
119 |
+
);
|
120 |
+
}
|
121 |
+
$log->setData($data);
|
122 |
+
$log->save();
|
123 |
+
|
124 |
+
Mage::getSingleton('customer/session')->addSuccess(Mage::helper('sponsorship')->__('Your request has been submitted, you will soon receive an email confirmation.'));
|
125 |
+
$this->_redirect('*/*/');
|
126 |
+
}
|
127 |
+
|
128 |
+
catch (Exception $e) {
|
129 |
+
Mage::log($e->getMessage());
|
130 |
+
Mage::getSingleton('customer/session')->addError(Mage::helper('sponsorship')->__("An error occurred while saving your request."));
|
131 |
+
$this->_redirect('*/*/');
|
132 |
+
}
|
133 |
+
}
|
134 |
+
elseif ($resultValidate == 'inactif' )
|
135 |
+
{
|
136 |
+
$this->_redirect('*/*/');
|
137 |
+
}
|
138 |
+
elseif ($resultValidate == 'account' )
|
139 |
+
{
|
140 |
+
$this->_redirectUrl(Mage::helper('customer')->getAccountUrl().'edit');
|
141 |
+
}
|
142 |
+
elseif ($resultValidate == 'points' )
|
143 |
+
{
|
144 |
+
$this->_redirect('*/*/change', Array('module'=>$module, 'type'=>$type));
|
145 |
+
}
|
146 |
+
elseif ($resultValidate == 'mail' )
|
147 |
+
{
|
148 |
+
Mage::getSingleton('customer/session')->addError(Mage::helper('sponsorship')->__("An error occurred while sending mail."));
|
149 |
+
$this->_redirect('*/*/change', Array('module'=>$module, 'type'=>$type));
|
150 |
+
}
|
151 |
+
}
|
152 |
+
}
|
153 |
+
|
154 |
+
protected function validateChange($module, $type, $points='')
|
155 |
+
{
|
156 |
+
$options = Mage::getBlockSingleton('sponsorship/customer_account_pointsDetail');
|
157 |
+
$session = Mage::getSingleton('customer/session');
|
158 |
+
|
159 |
+
$Module = ucfirst($module);
|
160 |
+
$Type = ucfirst($type);
|
161 |
+
|
162 |
+
$changeEnabled = 'get'.$Module.$Type.'Config';
|
163 |
+
$moduleEnabled = 'get'.$Module.'EnabledConfig';
|
164 |
+
|
165 |
+
if (($options->$moduleEnabled()==1 && $options->$changeEnabled()==1))
|
166 |
+
{
|
167 |
+
$validate = 'validate'.$Type;
|
168 |
+
return $this->$validate($module,$points);
|
169 |
+
}
|
170 |
+
else
|
171 |
+
{
|
172 |
+
$session->addError(Mage::helper('sponsorship')->__('The exchange of %s points in %s is disabled.',$this->__($module),$this->__($type)));
|
173 |
+
return 'inactif';
|
174 |
+
}
|
175 |
+
}
|
176 |
+
protected function validateCoupon ($module, $points='')
|
177 |
+
{
|
178 |
+
$validate = 'valide';
|
179 |
+
$customerId = Mage::getSingleton('customer/session')->getId();
|
180 |
+
$customer = Mage::getModel("customer/customer")->load($customerId);
|
181 |
+
|
182 |
+
//vérification que les points à changer sonts inférieurs aux points du client
|
183 |
+
if ($points != '')
|
184 |
+
{
|
185 |
+
$data = 'get'.ucfirst($module).'Points';
|
186 |
+
$cPoints = $customer->$data();
|
187 |
+
if ($points>$cPoints)
|
188 |
+
{
|
189 |
+
Mage::getSingleton('customer/session')->addError(Mage::helper('sponsorship')->__("You do not have as many points."));
|
190 |
+
$validate = 'points';
|
191 |
+
}
|
192 |
+
else
|
193 |
+
{
|
194 |
+
//création de la règle panier---------------------------------------------------
|
195 |
+
$options = Mage::getBlockSingleton('sponsorship/customer_account_pointsDetail');
|
196 |
+
$srModel = Mage::getModel('salesrule/rule');
|
197 |
+
$date = now();
|
198 |
+
$chars = array("-", ":", " ");
|
199 |
+
$simpledate = str_replace($chars, "", $date);
|
200 |
+
$couponCode = $customerId."-".$points.$simpledate;//idClient-date-module-somme
|
201 |
+
$name = $this->__("%s points exchange for customer (%s)", $this->__($module), $customerId);
|
202 |
+
$description = $name;
|
203 |
+
$customerGroupId = $customer->getGroupId();
|
204 |
+
$discountAmount = $this->getValue ($points, "coupon", $module);
|
205 |
+
$websiteId = $customer->getWebsiteId();
|
206 |
+
$data = array
|
207 |
+
(
|
208 |
+
"name" => $name,
|
209 |
+
"description" => $description,
|
210 |
+
"from_date" => $date,
|
211 |
+
"coupon_code" => $couponCode,
|
212 |
+
"uses_per_coupon" => 1,
|
213 |
+
//"uses_per_customer" => 1,
|
214 |
+
"customer_group_ids" => Array(0 => $customerGroupId),//get customer group
|
215 |
+
"is_active" => 1,
|
216 |
+
"conditions_serialized" => 'a:7:{s:4:"type";s:32:"salesrule/rule_condition_combine";s:9:"attribute";N;s:8:"operator";N;s:5:"value";s:1:"1";s:18:"is_value_processed";N;s:10:"aggregator";s:3:"all";s:10:"conditions";a:1:{i:0;a:5:{s:4:"type";s:32:"salesrule/rule_condition_address";s:9:"attribute";s:9:"total_qty";s:8:"operator";s:1:">";s:5:"value";s:1:"0";s:18:"is_value_processed";b:0;}}}',
|
217 |
+
"actions_serialized" => 'a:6:{s:4:"type";s:40:"salesrule/rule_condition_product_combine";s:9:"attribute";N;s:8:"operator";N;s:5:"value";s:1:"1";s:18:"is_value_processed";N;s:10:"aggregator";s:3:"all";}',
|
218 |
+
"stop_rules_processing" => 0,
|
219 |
+
"is_advanced" => 1,
|
220 |
+
"sort_order" => 0,
|
221 |
+
"simple_action" => "by_fixed",
|
222 |
+
"discount_amount" => $discountAmount,
|
223 |
+
"discount_qty" => 1.0000,
|
224 |
+
"discount_step" => 0,
|
225 |
+
"simple_free_shipping" => 0,
|
226 |
+
"times_used" => 0,
|
227 |
+
"is_rss" => 1,
|
228 |
+
"website_ids" => Array(0 => $websiteId)//get website id
|
229 |
+
);
|
230 |
+
$srModel->setData($data);
|
231 |
+
$srModel->save();
|
232 |
+
//envoi du mail--------------------------------------------------------------
|
233 |
+
//construction du message
|
234 |
+
$mailTemplate = Mage::getModel('sponsorship/Core_Email_Template');
|
235 |
+
|
236 |
+
$sender_name = Mage::getStoreConfig('trans_email/ident_sales/name');
|
237 |
+
$sender_email = Mage::getStoreConfig('trans_email/ident_sales/email');
|
238 |
+
|
239 |
+
$subject = $this->__('%s vouchers points exchange', Mage::helper('sponsorship/mail')->getStoreName());
|
240 |
+
|
241 |
+
$sender = array("name"=>$sender_name, "email"=>$sender_email);
|
242 |
+
$recipient_email = $customer->getData('email');
|
243 |
+
|
244 |
+
$postObject = new Varien_Object();
|
245 |
+
$postObject->setData(Array ("sender_name" => $sender_name,
|
246 |
+
"sender_email" => $sender_email,
|
247 |
+
"recipient_firstname" => $customer->getFirstname(),
|
248 |
+
"recipient_lastname" => $customer->getLastname(),
|
249 |
+
"discount_amount" => $discountAmount,
|
250 |
+
"subject" => $subject,
|
251 |
+
"coupon_code" => $couponCode,
|
252 |
+
"store_name" => Mage::helper('sponsorship/mail')->getStoreName()
|
253 |
+
));
|
254 |
+
|
255 |
+
$mailTemplate->setDesignConfig(array('area' => 'fronted'))
|
256 |
+
->setReplyTo($sender_email)
|
257 |
+
//->setReturnPath($sender_email)
|
258 |
+
->sendTransactional(
|
259 |
+
"sponsorship_email_coupon",
|
260 |
+
$sender,
|
261 |
+
$recipient_email,
|
262 |
+
$customer->getFirstname().' '.$customer->getLastname(),
|
263 |
+
array('data' => $postObject)
|
264 |
+
);
|
265 |
+
if (!$mailTemplate->getSentSuccess())
|
266 |
+
{
|
267 |
+
$validate = "mail";
|
268 |
+
}
|
269 |
+
|
270 |
+
}
|
271 |
+
}
|
272 |
+
return $validate;
|
273 |
+
}
|
274 |
+
|
275 |
+
protected function validateGift ($module, $points='')
|
276 |
+
{
|
277 |
+
return 'valide';
|
278 |
+
}
|
279 |
+
|
280 |
+
protected function validateCash ($module, $points=0)
|
281 |
+
{
|
282 |
+
$validate = 'valide';
|
283 |
+
$customerId = Mage::getSingleton('customer/session')->getId();
|
284 |
+
$maxCash = "";
|
285 |
+
$options = Mage::getBlockSingleton('sponsorship/customer_account_pointsDetail');
|
286 |
+
|
287 |
+
//Validation qu'un Iban est renseigné
|
288 |
+
$customer = Mage::getModel("customer/customer")->load($customerId);
|
289 |
+
|
290 |
+
if (!$customer->getIban()) {
|
291 |
+
Mage::getSingleton('customer/session')->addError(Mage::helper('sponsorship')->__('To change your points into cash, you must indicate your IBAN.'));
|
292 |
+
$validate = 'account';
|
293 |
+
}
|
294 |
+
|
295 |
+
//Validation qu'un Siret est renseigné si le max de cash pour un particulier est atteint
|
296 |
+
if ($module=='sponsor') {
|
297 |
+
$maxCash = $options->getSponsorMaxCashConfig ();
|
298 |
+
$timeMaxCash = $options->getSponsorTimeMaxCashConfig ();
|
299 |
+
}
|
300 |
+
elseif ($module=='fidelity') {
|
301 |
+
$maxCash = $options->getFidelityMaxCashConfig ();
|
302 |
+
$timeMaxCash = $options->getFidelityTimeMaxCashConfig ();
|
303 |
+
}
|
304 |
+
$resource = Mage::getSingleton('core/resource');
|
305 |
+
$read = $resource->getConnection('core_read');
|
306 |
+
$select = $read->select()
|
307 |
+
->from($resource->getTableName('sponsorship/change'), 'SUM(points)')
|
308 |
+
->where('customer_id=?', $customerId)
|
309 |
+
->where('module=?', $module)
|
310 |
+
->where('type=?', 'cash')
|
311 |
+
->where('statut!=?', 'canceled')
|
312 |
+
->where('TO_DAYS(NOW()) - TO_DAYS(datetime) <=?', $timeMaxCash);
|
313 |
+
|
314 |
+
$cashPoints = $read->fetchOne($select);
|
315 |
+
|
316 |
+
//Addition des points déjà changés avec les points demandés
|
317 |
+
$cashPoints = $points+$cashPoints;
|
318 |
+
|
319 |
+
//vérification que le total ne dépasse pas le maximum autorisé
|
320 |
+
if ($cashPoints >= $maxCash) {
|
321 |
+
if (!$customer->getSiret())
|
322 |
+
{
|
323 |
+
Mage::getSingleton('customer/session')->addError(Mage::helper('sponsorship')->__('To change more cash, you must specify a company number.'));
|
324 |
+
$validate = 'account';
|
325 |
+
}
|
326 |
+
}
|
327 |
+
|
328 |
+
//vérification que les points à changer sonts inférieurs aux points du client
|
329 |
+
if ($points != '')
|
330 |
+
{
|
331 |
+
$data = 'get'.ucfirst($module).'Points';
|
332 |
+
$cPoints = $customer->$data();
|
333 |
+
if ($points>$cPoints)
|
334 |
+
{
|
335 |
+
Mage::getSingleton('customer/session')->addError(Mage::helper('sponsorship')->__("You do not have as many points."));
|
336 |
+
$validate = 'points';
|
337 |
+
}
|
338 |
+
}
|
339 |
+
return $validate;
|
340 |
+
}
|
341 |
+
|
342 |
+
protected function getValue ($points, $type, $module)
|
343 |
+
{
|
344 |
+
//if ($type == 'cash')
|
345 |
+
//recuperation du taux de conversion
|
346 |
+
$options = Mage::getBlockSingleton('sponsorship/customer_account_pointsDetail');
|
347 |
+
$getPointsToCash = 'get'.ucfirst($module).'PointsToCashConfig';
|
348 |
+
$PointsToCash = $options->$getPointsToCash();
|
349 |
+
$value = round($points*$PointsToCash,2);
|
350 |
+
return $value;
|
351 |
+
}
|
352 |
+
}
|
app/code/community/Auguria/Sponsorship/etc/config.xml
ADDED
@@ -0,0 +1,336 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<!--
|
3 |
+
/**
|
4 |
+
* @category Auguria
|
5 |
+
* @package Auguria_Sponsorship
|
6 |
+
* @author Auguria
|
7 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
8 |
+
*/
|
9 |
+
-->
|
10 |
+
<config>
|
11 |
+
<modules>
|
12 |
+
<Auguria_Sponsorship>
|
13 |
+
<version>1.0.1</version>
|
14 |
+
</Auguria_Sponsorship>
|
15 |
+
</modules>
|
16 |
+
<frontend>
|
17 |
+
<secure_url>
|
18 |
+
<sponsorship_index>/sponsorship/index/</sponsorship_index>
|
19 |
+
<sponsorship_boost>/sponsorship/boost/</sponsorship_boost>
|
20 |
+
<sponsorship_points>/sponsorship/points/</sponsorship_points>
|
21 |
+
</secure_url>
|
22 |
+
<routers>
|
23 |
+
<sponsorship>
|
24 |
+
<use>standard</use>
|
25 |
+
<args>
|
26 |
+
<module>Auguria_Sponsorship</module>
|
27 |
+
<frontName>sponsorship</frontName>
|
28 |
+
</args>
|
29 |
+
</sponsorship>
|
30 |
+
</routers>
|
31 |
+
<layout>
|
32 |
+
<updates>
|
33 |
+
<sponsorship>
|
34 |
+
<file>sponsorship.xml</file>
|
35 |
+
</sponsorship>
|
36 |
+
</updates>
|
37 |
+
</layout>
|
38 |
+
<translate>
|
39 |
+
<modules>
|
40 |
+
<Auguria_Sponsorship>
|
41 |
+
<files>
|
42 |
+
<default>Auguria_Sponsorship.csv</default>
|
43 |
+
</files>
|
44 |
+
</Auguria_Sponsorship>
|
45 |
+
</modules>
|
46 |
+
</translate>
|
47 |
+
</frontend>
|
48 |
+
<admin>
|
49 |
+
<routers>
|
50 |
+
<sponsorship>
|
51 |
+
<use>admin</use>
|
52 |
+
<args>
|
53 |
+
<module>Auguria_Sponsorship</module>
|
54 |
+
<frontName>sponsorship</frontName>
|
55 |
+
</args>
|
56 |
+
</sponsorship>
|
57 |
+
</routers>
|
58 |
+
</admin>
|
59 |
+
<adminhtml>
|
60 |
+
<menu>
|
61 |
+
<sponsorship module="sponsorship">
|
62 |
+
<title>Fidelity and Sponsorship</title>
|
63 |
+
<sort_order>71</sort_order>
|
64 |
+
<children>
|
65 |
+
<invitations module="sponsorship">
|
66 |
+
<title>Invitations list</title>
|
67 |
+
<sort_order>0</sort_order>
|
68 |
+
<action>sponsorship/adminhtml_sponsorship</action>
|
69 |
+
</invitations>
|
70 |
+
<parrainages module="sponsorship">
|
71 |
+
<title>Sponsorships list</title>
|
72 |
+
<sort_order>0</sort_order>
|
73 |
+
<action>sponsorship/adminhtml_link</action>
|
74 |
+
</parrainages>
|
75 |
+
<echanges module="sponsorship">
|
76 |
+
<title>Points exchanges list</title>
|
77 |
+
<sort_order>1</sort_order>
|
78 |
+
<action>sponsorship/adminhtml_change</action>
|
79 |
+
</echanges>
|
80 |
+
</children>
|
81 |
+
</sponsorship>
|
82 |
+
</menu>
|
83 |
+
<acl>
|
84 |
+
<resources>
|
85 |
+
<all>
|
86 |
+
<title>Allow Everything</title>
|
87 |
+
</all>
|
88 |
+
<admin>
|
89 |
+
<children>
|
90 |
+
<system>
|
91 |
+
<children>
|
92 |
+
<config>
|
93 |
+
<children>
|
94 |
+
<sponsorship translate="title" module="sponsorship">
|
95 |
+
<title>Module Sponsorship</title>
|
96 |
+
</sponsorship>
|
97 |
+
</children>
|
98 |
+
</config>
|
99 |
+
</children>
|
100 |
+
</system>
|
101 |
+
<sponsorship module="sponsorship">
|
102 |
+
<title>Sponsorship</title>
|
103 |
+
<sort_order>80</sort_order>
|
104 |
+
<children>
|
105 |
+
<invitations module="sponsorship">
|
106 |
+
<title>Invitations list</title>
|
107 |
+
</invitations>
|
108 |
+
<parrainages module="sponsorship">
|
109 |
+
<title>Sponsorships list</title>
|
110 |
+
</parrainages>
|
111 |
+
<echanges module="sponsorship">
|
112 |
+
<title>Points exchanges list</title>
|
113 |
+
</echanges>
|
114 |
+
</children>
|
115 |
+
</sponsorship>
|
116 |
+
</children>
|
117 |
+
</admin>
|
118 |
+
</resources>
|
119 |
+
</acl>
|
120 |
+
<layout>
|
121 |
+
<updates>
|
122 |
+
<sponsorship>
|
123 |
+
<file>sponsorship.xml</file>
|
124 |
+
</sponsorship>
|
125 |
+
</updates>
|
126 |
+
</layout>
|
127 |
+
<translate>
|
128 |
+
<modules>
|
129 |
+
<Auguria_Sponsorship>
|
130 |
+
<files>
|
131 |
+
<auguria_sponsorship>Auguria_Sponsorship.csv</auguria_sponsorship>
|
132 |
+
</files>
|
133 |
+
</Auguria_Sponsorship>
|
134 |
+
</modules>
|
135 |
+
</translate>
|
136 |
+
</adminhtml>
|
137 |
+
<global>
|
138 |
+
<events>
|
139 |
+
<!-- Création éventuelle du lien de parrainage lors de la commande -->
|
140 |
+
<checkout_type_onepage_save_order_after>
|
141 |
+
<observers>
|
142 |
+
<set_sponsorship>
|
143 |
+
<type>singleton</type>
|
144 |
+
<class>Auguria_Sponsorship_Model_Observer</class>
|
145 |
+
<method>setSponsor</method>
|
146 |
+
</set_sponsorship>
|
147 |
+
</observers>
|
148 |
+
</checkout_type_onepage_save_order_after>
|
149 |
+
|
150 |
+
<!-- Incrémentation des points lors du paiement -->
|
151 |
+
<sales_order_payment_pay>
|
152 |
+
<observers>
|
153 |
+
<calc_points>
|
154 |
+
<type>singleton</type>
|
155 |
+
<class>Auguria_Sponsorship_Model_Observer</class>
|
156 |
+
<method>calcPoints</method>
|
157 |
+
</calc_points>
|
158 |
+
</observers>
|
159 |
+
</sales_order_payment_pay>
|
160 |
+
</events>
|
161 |
+
<fieldsets>
|
162 |
+
<sales_convert_quote_item>
|
163 |
+
<cart_fidelity_points>
|
164 |
+
<to_order_item>*</to_order_item>
|
165 |
+
</cart_fidelity_points>
|
166 |
+
<cart_sponsor_points>
|
167 |
+
<to_order_item>*</to_order_item>
|
168 |
+
</cart_sponsor_points>
|
169 |
+
</sales_convert_quote_item>
|
170 |
+
<sales_convert_order_item>
|
171 |
+
<cart_fidelity_points>
|
172 |
+
<to_quote_item>*</to_quote_item>
|
173 |
+
</cart_fidelity_points>
|
174 |
+
<cart_sponsor_points>
|
175 |
+
<to_quote_item>*</to_quote_item>
|
176 |
+
</cart_sponsor_points>
|
177 |
+
</sales_convert_order_item>
|
178 |
+
</fieldsets>
|
179 |
+
<rewrite>
|
180 |
+
<auguria_sponsorship_customer_account>
|
181 |
+
<from><![CDATA[#^/customer/account/#]]></from><!-- si index à la place de account : ne pas mettre index -->
|
182 |
+
<to>/sponsorship/customer_account/</to>
|
183 |
+
</auguria_sponsorship_customer_account>
|
184 |
+
</rewrite>
|
185 |
+
<models>
|
186 |
+
<catalogrule_mysql4>
|
187 |
+
<rewrite>
|
188 |
+
<rule>Auguria_Sponsorship_Model_Mysql4_Rule</rule>
|
189 |
+
</rewrite>
|
190 |
+
</catalogrule_mysql4>
|
191 |
+
<salesrule>
|
192 |
+
<rewrite>
|
193 |
+
<validator>Auguria_Sponsorship_Model_Validator</validator>
|
194 |
+
</rewrite>
|
195 |
+
</salesrule>
|
196 |
+
<customer>
|
197 |
+
<rewrite>
|
198 |
+
<customer>Auguria_Sponsorship_Model_Customer_Customer</customer>
|
199 |
+
</rewrite>
|
200 |
+
</customer>
|
201 |
+
<sponsorship>
|
202 |
+
<class>Auguria_Sponsorship_Model</class>
|
203 |
+
<resourceModel>sponsorship_mysql4</resourceModel>
|
204 |
+
</sponsorship>
|
205 |
+
<sponsorship_mysql4>
|
206 |
+
<class>Auguria_Sponsorship_Model_Mysql4</class>
|
207 |
+
<entities>
|
208 |
+
<sponsorship>
|
209 |
+
<table>sponsorship</table>
|
210 |
+
</sponsorship>
|
211 |
+
<catalogfidelitypoint>
|
212 |
+
<table>catalogrule_product_fidelity_point</table>
|
213 |
+
</catalogfidelitypoint>
|
214 |
+
<catalogsponsorpoint>
|
215 |
+
<table>catalogrule_product_sponsor_point</table>
|
216 |
+
</catalogsponsorpoint>
|
217 |
+
<fidelitylog>
|
218 |
+
<table>sponsorship_fidelity_log</table>
|
219 |
+
</fidelitylog>
|
220 |
+
<sponsorlog>
|
221 |
+
<table>sponsorship_sponsor_log</table>
|
222 |
+
</sponsorlog>
|
223 |
+
<change>
|
224 |
+
<table>sponsorship_change</table>
|
225 |
+
</change>
|
226 |
+
<link>
|
227 |
+
<table>sponsorship_change</table>
|
228 |
+
</link>
|
229 |
+
</entities>
|
230 |
+
</sponsorship_mysql4>
|
231 |
+
</models>
|
232 |
+
<resources>
|
233 |
+
<sponsorship_setup>
|
234 |
+
<setup>
|
235 |
+
<module>Auguria_Sponsorship</module>
|
236 |
+
</setup>
|
237 |
+
<connection>
|
238 |
+
<use>core_setup</use>
|
239 |
+
</connection>
|
240 |
+
</sponsorship_setup>
|
241 |
+
<sponsorship_write>
|
242 |
+
<connection>
|
243 |
+
<use>core_write</use>
|
244 |
+
</connection>
|
245 |
+
</sponsorship_write>
|
246 |
+
<sponsorship_read>
|
247 |
+
<connection>
|
248 |
+
<use>core_read</use>
|
249 |
+
</connection>
|
250 |
+
</sponsorship_read>
|
251 |
+
</resources>
|
252 |
+
<blocks>
|
253 |
+
<sponsorship>
|
254 |
+
<class>Auguria_Sponsorship_Block</class>
|
255 |
+
</sponsorship>
|
256 |
+
<adminhtml>
|
257 |
+
<rewrite>
|
258 |
+
<promo_catalog_edit_tab_actions>Auguria_Sponsorship_Block_Promo_Catalog_Edit_Tab_Actions</promo_catalog_edit_tab_actions>
|
259 |
+
<promo_quote_edit_tab_actions>Auguria_Sponsorship_Block_Promo_Quote_Edit_Tab_Actions</promo_quote_edit_tab_actions>
|
260 |
+
</rewrite>
|
261 |
+
</adminhtml>
|
262 |
+
<customer>
|
263 |
+
<rewrite>
|
264 |
+
<widget_name>Auguria_Sponsorship_Block_Customer_Widget_Name</widget_name>
|
265 |
+
</rewrite>
|
266 |
+
</customer>
|
267 |
+
</blocks>
|
268 |
+
<helpers>
|
269 |
+
<sponsorship>
|
270 |
+
<class>Auguria_Sponsorship_Helper</class>
|
271 |
+
</sponsorship>
|
272 |
+
</helpers>
|
273 |
+
<template>
|
274 |
+
<email>
|
275 |
+
<sponsorship_email_invitation translate="label" module="sponsorship">
|
276 |
+
<label>Sponsorship invitation</label>
|
277 |
+
<file>sponsorship_invitation.html</file>
|
278 |
+
<type>html</type>
|
279 |
+
</sponsorship_email_invitation>
|
280 |
+
<sponsorship_email_coupon translate="label" module="sponsorship">
|
281 |
+
<label>Sponsorship coupon</label>
|
282 |
+
<file>sponsorship_coupon.html</file>
|
283 |
+
<type>html</type>
|
284 |
+
</sponsorship_email_coupon>
|
285 |
+
</email>
|
286 |
+
</template>
|
287 |
+
</global>
|
288 |
+
|
289 |
+
<default>
|
290 |
+
<sponsorship>
|
291 |
+
<sponsor>
|
292 |
+
<sponsor_enabled>1</sponsor_enabled>
|
293 |
+
<sponsor_cash>1</sponsor_cash>
|
294 |
+
<sponsor_coupon>1</sponsor_coupon>
|
295 |
+
<sponsor_gift>0</sponsor_gift>
|
296 |
+
<sponsor_max_cash>350</sponsor_max_cash>
|
297 |
+
<sponsor_time_max_cash>90</sponsor_time_max_cash>
|
298 |
+
<sponsor_points_to_cash>1</sponsor_points_to_cash>
|
299 |
+
<sponsor_optional_order>1</sponsor_optional_order>
|
300 |
+
<sponsor_link_validity>365</sponsor_link_validity>
|
301 |
+
<sponsor_levels>100</sponsor_levels>
|
302 |
+
<sponsor_percent>50</sponsor_percent>
|
303 |
+
</sponsor>
|
304 |
+
<invitation_email>
|
305 |
+
<sponsor_invitation_validity>365</sponsor_invitation_validity>
|
306 |
+
<time_before_boost>7</time_before_boost>
|
307 |
+
<max_recipients>20</max_recipients>
|
308 |
+
<email_template>sponsorship_email_invitation</email_template>
|
309 |
+
</invitation_email>
|
310 |
+
<fidelity>
|
311 |
+
<fidelity_enabled>1</fidelity_enabled>
|
312 |
+
<fidelity_cash>1</fidelity_cash>
|
313 |
+
<fidelity_coupon>1</fidelity_coupon>
|
314 |
+
<fidelity_gift>0</fidelity_gift>
|
315 |
+
<fidelity_max_cash>350</fidelity_max_cash>
|
316 |
+
<fidelity_time_max_cash>90</fidelity_time_max_cash>
|
317 |
+
<fidelity_points_to_cash>1</fidelity_points_to_cash>
|
318 |
+
</fidelity>
|
319 |
+
<change>
|
320 |
+
<email_template_coupon>sponsorship_email_coupon</email_template_coupon>
|
321 |
+
</change>
|
322 |
+
</sponsorship>
|
323 |
+
</default>
|
324 |
+
<crontab>
|
325 |
+
<jobs>
|
326 |
+
<sponsorship_boost>
|
327 |
+
<schedule>
|
328 |
+
<cron_expr>0 */1 * * *</cron_expr>
|
329 |
+
</schedule>
|
330 |
+
<run>
|
331 |
+
<model>sponsorship/autoBoost::process</model>
|
332 |
+
</run>
|
333 |
+
</sponsorship_boost>
|
334 |
+
</jobs>
|
335 |
+
</crontab>
|
336 |
+
</config>
|
app/code/community/Auguria/Sponsorship/etc/system.xml
ADDED
@@ -0,0 +1,272 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<!--
|
2 |
+
/**
|
3 |
+
* @category Auguria
|
4 |
+
* @package Auguria_Sponsorship
|
5 |
+
* @author Auguria
|
6 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
7 |
+
*/
|
8 |
+
-->
|
9 |
+
<config>
|
10 |
+
<sections>
|
11 |
+
<sponsorship translate="label" module="sponsorship">
|
12 |
+
<label>Fidelity and Sponsorship</label>
|
13 |
+
<tab>general</tab>
|
14 |
+
<frontend_type>text</frontend_type>
|
15 |
+
<sort_order>200</sort_order>
|
16 |
+
<show_in_default>1</show_in_default>
|
17 |
+
<show_in_website>1</show_in_website>
|
18 |
+
<show_in_store>1</show_in_store>
|
19 |
+
<groups>
|
20 |
+
<sponsor translate="label">
|
21 |
+
<label>Sponsorship options</label>
|
22 |
+
<frontend_type>text</frontend_type>
|
23 |
+
<sort_order>1</sort_order>
|
24 |
+
<show_in_default>1</show_in_default>
|
25 |
+
<show_in_website>1</show_in_website>
|
26 |
+
<show_in_store>1</show_in_store>
|
27 |
+
<fields>
|
28 |
+
<sponsor_enabled translate="label">
|
29 |
+
<label>Sponsorship module activated</label>
|
30 |
+
<frontend_type>select</frontend_type>
|
31 |
+
<source_model>adminhtml/system_config_source_yesno</source_model>
|
32 |
+
<sort_order>1</sort_order>
|
33 |
+
<show_in_default>1</show_in_default>
|
34 |
+
<show_in_website>1</show_in_website>
|
35 |
+
<show_in_store>1</show_in_store>
|
36 |
+
</sponsor_enabled>
|
37 |
+
<sponsor_cash translate="label">
|
38 |
+
<label>Cash exchange enabled</label>
|
39 |
+
<frontend_type>select</frontend_type>
|
40 |
+
<source_model>adminhtml/system_config_source_yesno</source_model>
|
41 |
+
<sort_order>2</sort_order>
|
42 |
+
<show_in_default>1</show_in_default>
|
43 |
+
<show_in_website>1</show_in_website>
|
44 |
+
<show_in_store>1</show_in_store>
|
45 |
+
</sponsor_cash>
|
46 |
+
<sponsor_coupon translate="label">
|
47 |
+
<label>Voucher exchange enabled</label>
|
48 |
+
<frontend_type>select</frontend_type>
|
49 |
+
<source_model>adminhtml/system_config_source_yesno</source_model>
|
50 |
+
<sort_order>3</sort_order>
|
51 |
+
<show_in_default>1</show_in_default>
|
52 |
+
<show_in_website>1</show_in_website>
|
53 |
+
<show_in_store>1</show_in_store>
|
54 |
+
</sponsor_coupon>
|
55 |
+
<sponsor_gift translate="label">
|
56 |
+
<label>Gift exchange enabled</label>
|
57 |
+
<frontend_type>select</frontend_type>
|
58 |
+
<source_model>adminhtml/system_config_source_yesno</source_model>
|
59 |
+
<sort_order>4</sort_order>
|
60 |
+
<show_in_default>1</show_in_default>
|
61 |
+
<show_in_website>1</show_in_website>
|
62 |
+
<show_in_store>1</show_in_store>
|
63 |
+
</sponsor_gift>
|
64 |
+
<sponsor_max_cash translate="label">
|
65 |
+
<label>Maximum amount permitted without company number</label>
|
66 |
+
<frontend_type>text</frontend_type>
|
67 |
+
<backend_model>sponsorship/adminhtml_system_config_backend_sponsorship_float</backend_model>
|
68 |
+
<sort_order>5</sort_order>
|
69 |
+
<show_in_default>1</show_in_default>
|
70 |
+
<show_in_website>1</show_in_website>
|
71 |
+
<show_in_store>1</show_in_store>
|
72 |
+
</sponsor_max_cash>
|
73 |
+
<sponsor_time_max_cash translate="label">
|
74 |
+
<label>Calculation period of the maximum allowed for an individual (days)</label>
|
75 |
+
<frontend_type>text</frontend_type>
|
76 |
+
<backend_model>sponsorship/adminhtml_system_config_backend_sponsorship_entier</backend_model>
|
77 |
+
<sort_order>6</sort_order>
|
78 |
+
<show_in_default>1</show_in_default>
|
79 |
+
<show_in_website>1</show_in_website>
|
80 |
+
<show_in_store>1</show_in_store>
|
81 |
+
</sponsor_time_max_cash>
|
82 |
+
<sponsor_points_to_cash translate="label">
|
83 |
+
<label>Conversion rate of points in currency</label>
|
84 |
+
<frontend_type>text</frontend_type>
|
85 |
+
<backend_model>sponsorship/adminhtml_system_config_backend_sponsorship_float</backend_model>
|
86 |
+
<sort_order>7</sort_order>
|
87 |
+
<show_in_default>1</show_in_default>
|
88 |
+
<show_in_website>1</show_in_website>
|
89 |
+
<show_in_store>1</show_in_store>
|
90 |
+
</sponsor_points_to_cash>
|
91 |
+
<sponsor_optional_order translate="label">
|
92 |
+
<label>Allow to send invitations to customers who have never ordered</label>
|
93 |
+
<frontend_type>select</frontend_type>
|
94 |
+
<source_model>adminhtml/system_config_source_yesno</source_model>
|
95 |
+
<sort_order>8</sort_order>
|
96 |
+
<show_in_default>1</show_in_default>
|
97 |
+
<show_in_website>1</show_in_website>
|
98 |
+
<show_in_store>1</show_in_store>
|
99 |
+
</sponsor_optional_order>
|
100 |
+
<sponsor_link_validity translate="label">
|
101 |
+
<label>Inactivity time before removal of the sponsorship link (days)</label>
|
102 |
+
<frontend_type>text</frontend_type>
|
103 |
+
<backend_model>sponsorship/adminhtml_system_config_backend_sponsorship_entier</backend_model>
|
104 |
+
<sort_order>10</sort_order>
|
105 |
+
<show_in_default>1</show_in_default>
|
106 |
+
<show_in_website>1</show_in_website>
|
107 |
+
<show_in_store>1</show_in_store>
|
108 |
+
</sponsor_link_validity>
|
109 |
+
<sponsor_levels translate="label">
|
110 |
+
<label>Maximum levels of sponsorship</label>
|
111 |
+
<frontend_type>text</frontend_type>
|
112 |
+
<backend_model>sponsorship/adminhtml_system_config_backend_sponsorship_entier</backend_model>
|
113 |
+
<sort_order>11</sort_order>
|
114 |
+
<show_in_default>1</show_in_default>
|
115 |
+
<show_in_website>1</show_in_website>
|
116 |
+
<show_in_store>1</show_in_store>
|
117 |
+
</sponsor_levels>
|
118 |
+
<sponsor_percent translate="label">
|
119 |
+
<label>Ratio applied from level 2 to calculate the points of the sponsor (in percentage)</label>
|
120 |
+
<frontend_type>text</frontend_type>
|
121 |
+
<backend_model>sponsorship/adminhtml_system_config_backend_sponsorship_float</backend_model>
|
122 |
+
<sort_order>12</sort_order>
|
123 |
+
<show_in_default>1</show_in_default>
|
124 |
+
<show_in_website>1</show_in_website>
|
125 |
+
<show_in_store>1</show_in_store>
|
126 |
+
</sponsor_percent>
|
127 |
+
</fields>
|
128 |
+
</sponsor>
|
129 |
+
<fidelity translate="label">
|
130 |
+
<label>Fidelity options</label>
|
131 |
+
<frontend_type>text</frontend_type>
|
132 |
+
<sort_order>2</sort_order>
|
133 |
+
<show_in_default>1</show_in_default>
|
134 |
+
<show_in_website>1</show_in_website>
|
135 |
+
<show_in_store>1</show_in_store>
|
136 |
+
<fields>
|
137 |
+
<fidelity_enabled translate="label">
|
138 |
+
<label>Fidelity module activated</label>
|
139 |
+
<frontend_type>select</frontend_type>
|
140 |
+
<source_model>adminhtml/system_config_source_yesno</source_model>
|
141 |
+
<sort_order>1</sort_order>
|
142 |
+
<show_in_default>1</show_in_default>
|
143 |
+
<show_in_website>1</show_in_website>
|
144 |
+
<show_in_store>1</show_in_store>
|
145 |
+
</fidelity_enabled>
|
146 |
+
<fidelity_cash translate="label">
|
147 |
+
<label>Cash exchange enabled</label>
|
148 |
+
<frontend_type>select</frontend_type>
|
149 |
+
<source_model>adminhtml/system_config_source_yesno</source_model>
|
150 |
+
<sort_order>2</sort_order>
|
151 |
+
<show_in_default>1</show_in_default>
|
152 |
+
<show_in_website>1</show_in_website>
|
153 |
+
<show_in_store>1</show_in_store>
|
154 |
+
</fidelity_cash>
|
155 |
+
<fidelity_coupon translate="label">
|
156 |
+
<label>Voucher exchange enabled</label>
|
157 |
+
<frontend_type>select</frontend_type>
|
158 |
+
<source_model>adminhtml/system_config_source_yesno</source_model>
|
159 |
+
<sort_order>3</sort_order>
|
160 |
+
<show_in_default>1</show_in_default>
|
161 |
+
<show_in_website>1</show_in_website>
|
162 |
+
<show_in_store>1</show_in_store>
|
163 |
+
</fidelity_coupon>
|
164 |
+
<fidelity_gift translate="label">
|
165 |
+
<label>Gift exchange enabled</label>
|
166 |
+
<frontend_type>select</frontend_type>
|
167 |
+
<source_model>adminhtml/system_config_source_yesno</source_model>
|
168 |
+
<sort_order>4</sort_order>
|
169 |
+
<show_in_default>1</show_in_default>
|
170 |
+
<show_in_website>1</show_in_website>
|
171 |
+
<show_in_store>1</show_in_store>
|
172 |
+
</fidelity_gift>
|
173 |
+
<fidelity_max_cash>
|
174 |
+
<label>Maximum amount permitted without company number</label>
|
175 |
+
<frontend_type>text</frontend_type>
|
176 |
+
<backend_model>sponsorship/adminhtml_system_config_backend_sponsorship_float</backend_model>
|
177 |
+
<sort_order>5</sort_order>
|
178 |
+
<show_in_default>1</show_in_default>
|
179 |
+
<show_in_website>1</show_in_website>
|
180 |
+
<show_in_store>1</show_in_store>
|
181 |
+
</fidelity_max_cash>
|
182 |
+
<fidelity_time_max_cash>
|
183 |
+
<label>Calculation period of the maximum allowed for an individual (days)</label>
|
184 |
+
<frontend_type>text</frontend_type>
|
185 |
+
<backend_model>sponsorship/adminhtml_system_config_backend_sponsorship_entier</backend_model>
|
186 |
+
<sort_order>6</sort_order>
|
187 |
+
<show_in_default>1</show_in_default>
|
188 |
+
<show_in_website>1</show_in_website>
|
189 |
+
<show_in_store>1</show_in_store>
|
190 |
+
</fidelity_time_max_cash>
|
191 |
+
<fidelity_points_to_cash>
|
192 |
+
<label>Conversion rate of points in currency</label>
|
193 |
+
<frontend_type>text</frontend_type>
|
194 |
+
<backend_model>sponsorship/adminhtml_system_config_backend_sponsorship_float</backend_model>
|
195 |
+
<sort_order>7</sort_order>
|
196 |
+
<show_in_default>1</show_in_default>
|
197 |
+
<show_in_website>1</show_in_website>
|
198 |
+
<show_in_store>1</show_in_store>
|
199 |
+
</fidelity_points_to_cash>
|
200 |
+
</fields>
|
201 |
+
</fidelity>
|
202 |
+
<invitation_email translate="label">
|
203 |
+
<label>Sponsorship mail options</label>
|
204 |
+
<frontend_type>text</frontend_type>
|
205 |
+
<sort_order>3</sort_order>
|
206 |
+
<show_in_default>1</show_in_default>
|
207 |
+
<show_in_website>1</show_in_website>
|
208 |
+
<show_in_store>1</show_in_store>
|
209 |
+
<fields>
|
210 |
+
<sponsor_invitation_validity translate="label">
|
211 |
+
<label>Time validity invitations (days)</label>
|
212 |
+
<frontend_type>text</frontend_type>
|
213 |
+
<backend_model>sponsorship/adminhtml_system_config_backend_sponsorship_entier</backend_model>
|
214 |
+
<sort_order>1</sort_order>
|
215 |
+
<show_in_default>1</show_in_default>
|
216 |
+
<show_in_website>1</show_in_website>
|
217 |
+
<show_in_store>1</show_in_store>
|
218 |
+
</sponsor_invitation_validity>
|
219 |
+
<time_before_boost translate="label">
|
220 |
+
<label>Time to send it automatically (days)</label>
|
221 |
+
<frontend_type>text</frontend_type>
|
222 |
+
<backend_model>sponsorship/adminhtml_system_config_backend_sponsorship_entier</backend_model>
|
223 |
+
<sort_order>5</sort_order>
|
224 |
+
<show_in_default>1</show_in_default>
|
225 |
+
<show_in_website>1</show_in_website>
|
226 |
+
<show_in_store>1</show_in_store>
|
227 |
+
</time_before_boost>
|
228 |
+
<max_recipients translate="label">
|
229 |
+
<label>Max invitations</label>
|
230 |
+
<frontend_type>text</frontend_type>
|
231 |
+
<backend_model>sponsorship/adminhtml_system_config_backend_sponsorship_entier</backend_model>
|
232 |
+
<sort_order>10</sort_order>
|
233 |
+
<show_in_default>1</show_in_default>
|
234 |
+
<show_in_website>1</show_in_website>
|
235 |
+
<show_in_store>1</show_in_store>
|
236 |
+
</max_recipients>
|
237 |
+
<email_template translate="label">
|
238 |
+
<label>Email Template</label>
|
239 |
+
<frontend_type>text</frontend_type>
|
240 |
+
<!--
|
241 |
+
<frontend_type>select</frontend_type>
|
242 |
+
<source_model>adminhtml/system_config_source_email_template</source_model>
|
243 |
+
-->
|
244 |
+
<sort_order>20</sort_order>
|
245 |
+
<show_in_default>1</show_in_default>
|
246 |
+
<show_in_website>1</show_in_website>
|
247 |
+
<show_in_store>1</show_in_store>
|
248 |
+
</email_template>
|
249 |
+
</fields>
|
250 |
+
</invitation_email>
|
251 |
+
<change translate="label">
|
252 |
+
<label>Voucher exchange mail options</label>
|
253 |
+
<frontend_type>text</frontend_type>
|
254 |
+
<sort_order>4</sort_order>
|
255 |
+
<show_in_default>1</show_in_default>
|
256 |
+
<show_in_website>1</show_in_website>
|
257 |
+
<show_in_store>1</show_in_store>
|
258 |
+
<fields>
|
259 |
+
<email_template_coupon translate="label">
|
260 |
+
<label>Email Template</label>
|
261 |
+
<frontend_type>text</frontend_type>
|
262 |
+
<sort_order>1</sort_order>
|
263 |
+
<show_in_default>1</show_in_default>
|
264 |
+
<show_in_website>1</show_in_website>
|
265 |
+
<show_in_store>1</show_in_store>
|
266 |
+
</email_template_coupon>
|
267 |
+
</fields>
|
268 |
+
</change>
|
269 |
+
</groups>
|
270 |
+
</sponsorship>
|
271 |
+
</sections>
|
272 |
+
</config>
|
app/code/community/Auguria/Sponsorship/sql/sponsorship_setup/mysql4-install-0.1.0.php
ADDED
@@ -0,0 +1,41 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* @category Auguria
|
4 |
+
* @package Auguria_Sponsorship
|
5 |
+
* @author Auguria
|
6 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
7 |
+
*/
|
8 |
+
$installer = $this;
|
9 |
+
$installer->startSetup();
|
10 |
+
$date = now();
|
11 |
+
$storeId = Mage::app()->getStore()->getId();
|
12 |
+
$installer->run("
|
13 |
+
|
14 |
+
CREATE TABLE IF NOT EXISTS {$this->getTable('sponsorship')} (
|
15 |
+
`sponsorship_id` int(11) unsigned NOT NULL auto_increment,
|
16 |
+
`parent_id` int(10) unsigned NOT NULL,
|
17 |
+
`child_mail` varchar(255) NOT NULL default '',
|
18 |
+
`child_firstname` varchar(255) NOT NULL default '',
|
19 |
+
`child_lastname` varchar(255) NOT NULL default '',
|
20 |
+
`status` smallint(6) NOT NULL default '0',
|
21 |
+
`created_time` datetime NULL,
|
22 |
+
`update_time` datetime NULL,
|
23 |
+
PRIMARY KEY (`sponsorship_id`)
|
24 |
+
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
25 |
+
|
26 |
+
INSERT INTO `{$this->getTable('cms_page')}`
|
27 |
+
(`title`, `root_template`, `meta_keywords`, `meta_description`, `identifier`, `content_heading`, `content`, `creation_time`,
|
28 |
+
`update_time`, `is_active`, `sort_order`, `layout_update_xml`, `custom_theme`, `custom_theme_from`,
|
29 |
+
`custom_theme_to`)
|
30 |
+
VALUES (
|
31 |
+
'Sample of sponsorship principles', 'two_columns_right', 'Sponsorship', 'Information on sponsorship', 'sponsorship_info',
|
32 |
+
'Sample of sponsorship principles',
|
33 |
+
'<p>By sponsoring friends you can earn:</p>\r\n<ul class=\"disc\">\r\n<li>Cash</li>\r\n<li>Vouchers</li>\r\n</ul>\r\n<p>Every time one of your godson order, you win 5% of its order !</p>\r\n<p>But that\'s not all, if your godson sponsors too, you earn 50% of what your godson has won...</p>\r\n<p>For example,</p>\r\n<ul class=\"disc\">\r\n<li>your godson place an order of 100 euros (you win 5 points)</li>\r\n<li>your godson sponsors 2 friends who order 100 euros each (you win 5 points)</li>\r\n<li>the godchildren of your godson each sponsor 2 people who order 100 euros each (you win 5 points)...</li>\r\n</ul>\r\n<p>Then you can exchange your points into cash or vouchers.</p>\r\n<p style=\"text-align:right;\"><a href=\"../sponsorship\">Yes I want sponsors friends to earn cash or vouchers !</a></p>',
|
34 |
+
'$date', '$date', 1, 0, '', '', NULL , NULL
|
35 |
+
);
|
36 |
+
|
37 |
+
INSERT INTO `{$this->getTable('cms/page_store')}` (`page_id`, `store_id`) VALUES
|
38 |
+
(LAST_INSERT_ID(), $storeId);
|
39 |
+
");
|
40 |
+
|
41 |
+
$installer->endSetup();
|
app/code/community/Auguria/Sponsorship/sql/sponsorship_setup/mysql4-upgrade-0.1.0-0.1.1.php
ADDED
@@ -0,0 +1,68 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* @category Auguria
|
4 |
+
* @package Auguria_Sponsorship
|
5 |
+
* @author Auguria
|
6 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
7 |
+
*/
|
8 |
+
$setup = new Mage_Eav_Model_Entity_Setup('core_setup');
|
9 |
+
$setup->startSetup();
|
10 |
+
|
11 |
+
$setup->addAttribute('customer', 'sponsor', array(
|
12 |
+
'type' => 'int',
|
13 |
+
'backend' => '',
|
14 |
+
'frontend' => '',
|
15 |
+
'label' => 'Parrain',
|
16 |
+
'input' => 'text',
|
17 |
+
'class' => '',
|
18 |
+
'source' => '',
|
19 |
+
'visible' => true,
|
20 |
+
'required' => false,
|
21 |
+
'user_defined' => false,
|
22 |
+
'default' => '',
|
23 |
+
'searchable' => false,
|
24 |
+
'filterable' => false,
|
25 |
+
'comparable' => false,
|
26 |
+
'visible_on_front' => false,
|
27 |
+
'unique' => false,
|
28 |
+
));
|
29 |
+
|
30 |
+
$setup->addAttribute('customer', 'fidelity_points', array(
|
31 |
+
'type' => 'decimal',
|
32 |
+
'backend' => '',
|
33 |
+
'frontend' => '',
|
34 |
+
'label' => 'Points Fidélité',
|
35 |
+
'input' => 'text',
|
36 |
+
'class' => '',
|
37 |
+
'source' => '',
|
38 |
+
'visible' => true,
|
39 |
+
'required' => false,
|
40 |
+
'user_defined' => false,
|
41 |
+
'default' => 0,
|
42 |
+
'searchable' => false,
|
43 |
+
'filterable' => false,
|
44 |
+
'comparable' => false,
|
45 |
+
'visible_on_front' => false,
|
46 |
+
'unique' => false,
|
47 |
+
));
|
48 |
+
|
49 |
+
$setup->addAttribute('customer', 'sponsor_points', array(
|
50 |
+
'type' => 'decimal',
|
51 |
+
'backend' => '',
|
52 |
+
'frontend' => '',
|
53 |
+
'label' => 'Points de Parrainage',
|
54 |
+
'input' => 'text',
|
55 |
+
'class' => '',
|
56 |
+
'source' => '',
|
57 |
+
'visible' => true,
|
58 |
+
'required' => false,
|
59 |
+
'user_defined' => false,
|
60 |
+
'default' => 0,
|
61 |
+
'searchable' => false,
|
62 |
+
'filterable' => false,
|
63 |
+
'comparable' => false,
|
64 |
+
'visible_on_front' => false,
|
65 |
+
'unique' => false,
|
66 |
+
));
|
67 |
+
|
68 |
+
$setup->endSetup();
|
app/code/community/Auguria/Sponsorship/sql/sponsorship_setup/mysql4-upgrade-0.1.1-0.1.2.php
ADDED
@@ -0,0 +1,52 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* @category Auguria
|
4 |
+
* @package Auguria_Sponsorship
|
5 |
+
* @author Auguria
|
6 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
7 |
+
*/
|
8 |
+
$installer = $this;
|
9 |
+
|
10 |
+
$installer->startSetup();
|
11 |
+
|
12 |
+
$installer->run("
|
13 |
+
|
14 |
+
ALTER TABLE {$this->getTable('catalogrule_product')} CHANGE `action_operator` `action_operator`
|
15 |
+
ENUM( 'to_fixed', 'to_percent', 'by_fixed', 'by_percent', 'fidelity_points_to_percent', 'fidelity_points_to_fixed', 'sponsor_points_to_percent', 'sponsor_points_to_fixed' )
|
16 |
+
CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT 'to_fixed';
|
17 |
+
|
18 |
+
CREATE TABLE IF NOT EXISTS {$this->getTable('catalogrule_product_fidelity_point')} (
|
19 |
+
`rule_product_fidelity_point_id` int(10) unsigned NOT NULL auto_increment,
|
20 |
+
`rule_date` date NOT NULL default '0000-00-00',
|
21 |
+
`customer_group_id` smallint(5) unsigned NOT NULL default '0',
|
22 |
+
`product_id` int(10) unsigned NOT NULL default '0',
|
23 |
+
`rule_point` decimal(12,4) NOT NULL default '0.0000',
|
24 |
+
`website_id` smallint(5) unsigned NOT NULL,
|
25 |
+
`latest_start_date` date default NULL,
|
26 |
+
`earliest_end_date` date default NULL,
|
27 |
+
PRIMARY KEY (`rule_product_fidelity_point_id`),
|
28 |
+
UNIQUE KEY `rule_date` (`rule_date`,`website_id`,`customer_group_id`,`product_id`),
|
29 |
+
KEY `FK_catalogrule_product_fidelity_point_customergroup` (`customer_group_id`),
|
30 |
+
KEY `FK_catalogrule_product_fidelity_point_website` (`website_id`),
|
31 |
+
KEY `FK_CATALOGRULE_PRODUCT_FIDELITY_POINT_PRODUCT` (`product_id`)
|
32 |
+
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
33 |
+
|
34 |
+
CREATE TABLE IF NOT EXISTS {$this->getTable('catalogrule_product_sponsor_point')} (
|
35 |
+
`rule_product_sponsor_point_id` int(10) unsigned NOT NULL auto_increment,
|
36 |
+
`rule_date` date NOT NULL default '0000-00-00',
|
37 |
+
`customer_group_id` smallint(5) unsigned NOT NULL default '0',
|
38 |
+
`product_id` int(10) unsigned NOT NULL default '0',
|
39 |
+
`rule_point` decimal(12,4) NOT NULL default '0.0000',
|
40 |
+
`website_id` smallint(5) unsigned NOT NULL,
|
41 |
+
`latest_start_date` date default NULL,
|
42 |
+
`earliest_end_date` date default NULL,
|
43 |
+
PRIMARY KEY (`rule_product_sponsor_point_id`),
|
44 |
+
UNIQUE KEY `rule_date` (`rule_date`,`website_id`,`customer_group_id`,`product_id`),
|
45 |
+
KEY `FK_catalogrule_product_sponsor_point_customergroup` (`customer_group_id`),
|
46 |
+
KEY `FK_catalogrule_product_sponsor_point_website` (`website_id`),
|
47 |
+
KEY `FK_CATALOGRULE_PRODUCT_SPONSOR_POINT_PRODUCT` (`product_id`)
|
48 |
+
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
49 |
+
|
50 |
+
");
|
51 |
+
|
52 |
+
$installer->endSetup();
|
app/code/community/Auguria/Sponsorship/sql/sponsorship_setup/mysql4-upgrade-0.1.2-0.1.3.php
ADDED
@@ -0,0 +1,87 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* @category Auguria
|
4 |
+
* @package Auguria_Sponsorship
|
5 |
+
* @author Auguria
|
6 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
7 |
+
*/
|
8 |
+
$setup = new Mage_Sales_Model_Mysql4_Setup('core_setup');
|
9 |
+
$setup->startSetup();
|
10 |
+
|
11 |
+
$setup->addAttribute('order_item', 'catalog_fidelity_points', array(
|
12 |
+
'type' => 'decimal',
|
13 |
+
'backend' => '',
|
14 |
+
'frontend' => '',
|
15 |
+
'label' => 'Points Fidélité',
|
16 |
+
'input' => 'text',
|
17 |
+
'class' => '',
|
18 |
+
'source' => '',
|
19 |
+
'visible' => true,
|
20 |
+
'required' => false,
|
21 |
+
'user_defined' => false,
|
22 |
+
'default' => '',
|
23 |
+
'searchable' => false,
|
24 |
+
'filterable' => false,
|
25 |
+
'comparable' => false,
|
26 |
+
'visible_on_front' => false,
|
27 |
+
'unique' => false,
|
28 |
+
));
|
29 |
+
|
30 |
+
$setup->addAttribute('order_item', 'catalog_sponsor_points', array(
|
31 |
+
'type' => 'decimal',
|
32 |
+
'backend' => '',
|
33 |
+
'frontend' => '',
|
34 |
+
'label' => 'Points Parrainage',
|
35 |
+
'input' => 'text',
|
36 |
+
'class' => '',
|
37 |
+
'source' => '',
|
38 |
+
'visible' => true,
|
39 |
+
'required' => false,
|
40 |
+
'user_defined' => false,
|
41 |
+
'default' => '',
|
42 |
+
'searchable' => false,
|
43 |
+
'filterable' => false,
|
44 |
+
'comparable' => false,
|
45 |
+
'visible_on_front' => false,
|
46 |
+
'unique' => false,
|
47 |
+
));
|
48 |
+
|
49 |
+
$setup->addAttribute('order_item', 'cart_fidelity_points', array(
|
50 |
+
'type' => 'decimal',
|
51 |
+
'backend' => '',
|
52 |
+
'frontend' => '',
|
53 |
+
'label' => 'Points Fidélité',
|
54 |
+
'input' => 'text',
|
55 |
+
'class' => '',
|
56 |
+
'source' => '',
|
57 |
+
'visible' => true,
|
58 |
+
'required' => false,
|
59 |
+
'user_defined' => false,
|
60 |
+
'default' => '',
|
61 |
+
'searchable' => false,
|
62 |
+
'filterable' => false,
|
63 |
+
'comparable' => false,
|
64 |
+
'visible_on_front' => false,
|
65 |
+
'unique' => false,
|
66 |
+
));
|
67 |
+
|
68 |
+
$setup->addAttribute('order_item', 'cart_sponsor_points', array(
|
69 |
+
'type' => 'decimal',
|
70 |
+
'backend' => '',
|
71 |
+
'frontend' => '',
|
72 |
+
'label' => 'Points Parrainage',
|
73 |
+
'input' => 'text',
|
74 |
+
'class' => '',
|
75 |
+
'source' => '',
|
76 |
+
'visible' => true,
|
77 |
+
'required' => false,
|
78 |
+
'user_defined' => false,
|
79 |
+
'default' => '',
|
80 |
+
'searchable' => false,
|
81 |
+
'filterable' => false,
|
82 |
+
'comparable' => false,
|
83 |
+
'visible_on_front' => false,
|
84 |
+
'unique' => false,
|
85 |
+
));
|
86 |
+
|
87 |
+
$setup->endSetup();
|
app/code/community/Auguria/Sponsorship/sql/sponsorship_setup/mysql4-upgrade-0.1.3-0.1.4.php
ADDED
@@ -0,0 +1,40 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* @category Auguria
|
4 |
+
* @package Auguria_Sponsorship
|
5 |
+
* @author Auguria
|
6 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
7 |
+
*/
|
8 |
+
$installer = $this;
|
9 |
+
|
10 |
+
$installer->startSetup();
|
11 |
+
|
12 |
+
$installer->run("
|
13 |
+
|
14 |
+
CREATE TABLE IF NOT EXISTS {$this->getTable('sponsorship_fidelity_log')} (
|
15 |
+
`sponsorship_fidelity_log_id` int(11) unsigned NOT NULL auto_increment,
|
16 |
+
`customer_id` int(10) unsigned NOT NULL,
|
17 |
+
`record_id` int(10) unsigned NOT NULL,
|
18 |
+
`record_type` enum('order', 'gift', 'coupon_code', 'cash', 'admin') NOT NULL,
|
19 |
+
`datetime` datetime NOT NULL,
|
20 |
+
`points` decimal(12,4) NOT NULL default '0.0000',
|
21 |
+
PRIMARY KEY (`sponsorship_fidelity_log_id`),
|
22 |
+
KEY `INDEX_FIDELITY_LOG_CUSTOMER_ID` (`customer_id`),
|
23 |
+
KEY `INDEX_FIDELITY_LOG_RECORD_ID` (`record_id`)
|
24 |
+
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
25 |
+
|
26 |
+
CREATE TABLE IF NOT EXISTS {$this->getTable('sponsorship_sponsor_log')} (
|
27 |
+
`sponsorship_sponsor_log_id` int(10) unsigned NOT NULL auto_increment,
|
28 |
+
`godson_id` int(10) unsigned NOT NULL,
|
29 |
+
`sponsor_id` int(10) unsigned NOT NULL,
|
30 |
+
`record_id` int(10) unsigned NOT NULL,
|
31 |
+
`record_type` enum('order', 'gift', 'coupon_code', 'cash', 'admin') NOT NULL,
|
32 |
+
`datetime` datetime NOT NULL,
|
33 |
+
`points` decimal(12,4) NOT NULL default '0.0000',
|
34 |
+
PRIMARY KEY (`sponsorship_sponsor_log_id`),
|
35 |
+
KEY `INDEX_SPONSOR_LOG_GODSON_ID` (`godson_id`),
|
36 |
+
KEY `INDEX_SPONSOR_LOG_SPONSOR_ID` (`sponsor_id`)
|
37 |
+
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
38 |
+
");
|
39 |
+
|
40 |
+
$installer->endSetup();
|
app/code/community/Auguria/Sponsorship/sql/sponsorship_setup/mysql4-upgrade-0.1.4-0.1.5.php
ADDED
@@ -0,0 +1,49 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* @category Auguria
|
4 |
+
* @package Auguria_Sponsorship
|
5 |
+
* @author Auguria
|
6 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
7 |
+
*/
|
8 |
+
$setup = new Mage_Eav_Model_Entity_Setup('core_setup');
|
9 |
+
$setup->startSetup();
|
10 |
+
|
11 |
+
$setup->addAttribute('customer', 'iban', array(
|
12 |
+
'type' => 'varchar',
|
13 |
+
'backend' => '',
|
14 |
+
'frontend' => '',
|
15 |
+
'label' => 'Iban',
|
16 |
+
'input' => 'text',
|
17 |
+
'class' => '',
|
18 |
+
'source' => '',
|
19 |
+
'visible' => true,
|
20 |
+
'required' => false,
|
21 |
+
'user_defined' => true,
|
22 |
+
'default' => '',
|
23 |
+
'searchable' => false,
|
24 |
+
'filterable' => false,
|
25 |
+
'comparable' => false,
|
26 |
+
'visible_on_front' => true,
|
27 |
+
'unique' => false,
|
28 |
+
));
|
29 |
+
|
30 |
+
$setup->addAttribute('customer', 'siret', array(
|
31 |
+
'type' => 'varchar',
|
32 |
+
'backend' => '',
|
33 |
+
'frontend' => '',
|
34 |
+
'label' => 'Siret',
|
35 |
+
'input' => 'text',
|
36 |
+
'class' => '',
|
37 |
+
'source' => '',
|
38 |
+
'visible' => true,
|
39 |
+
'required' => false,
|
40 |
+
'user_defined' => true,
|
41 |
+
'default' => '',
|
42 |
+
'searchable' => false,
|
43 |
+
'filterable' => false,
|
44 |
+
'comparable' => false,
|
45 |
+
'visible_on_front' => true,
|
46 |
+
'unique' => false,
|
47 |
+
));
|
48 |
+
|
49 |
+
$setup->endSetup();
|
app/code/community/Auguria/Sponsorship/sql/sponsorship_setup/mysql4-upgrade-0.1.5-0.1.6.php
ADDED
@@ -0,0 +1,39 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* @category Auguria
|
4 |
+
* @package Auguria_Sponsorship
|
5 |
+
* @author Auguria
|
6 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
7 |
+
*/
|
8 |
+
$installer = $this;
|
9 |
+
|
10 |
+
$installer->startSetup();
|
11 |
+
|
12 |
+
$installer->run("
|
13 |
+
CREATE TABLE IF NOT EXISTS {$this->getTable('sponsorship_change')} (
|
14 |
+
`sponsorship_change_id` int(11) unsigned NOT NULL auto_increment,
|
15 |
+
`customer_id` int(10) unsigned NOT NULL,
|
16 |
+
`type` enum('gift', 'coupon', 'cash') NOT NULL,
|
17 |
+
`module` enum('fidelity', 'sponsor') NOT NULL,
|
18 |
+
`statut` enum('waiting', 'exported', 'solved', 'canceled') NOT NULL,
|
19 |
+
`datetime` datetime NOT NULL,
|
20 |
+
`points` decimal(12,4) NOT NULL default '0.0000',
|
21 |
+
`value` varchar(250) NOT NULL,
|
22 |
+
PRIMARY KEY (`sponsorship_change_id`),
|
23 |
+
KEY `INDEX_CHANGE_CUSTOMER_ID` (`customer_id`),
|
24 |
+
KEY `INDEX_CHANGE_TYPE` (`type`),
|
25 |
+
KEY `INDEX_CHANGE_MODULE` (`module`),
|
26 |
+
KEY `INDEX_CHANGE_STATUT` (`statut`)
|
27 |
+
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
28 |
+
");
|
29 |
+
|
30 |
+
$installer->getConnection()->changeColumn($this->getTable('sponsorship_sponsor_log'),
|
31 |
+
'record_type', 'record_type',
|
32 |
+
'enum("order","gift","coupon","cash","admin") CHARACTER SET utf8 NOT NULL'
|
33 |
+
);
|
34 |
+
$installer->getConnection()->changeColumn($this->getTable('sponsorship_fidelity_log'),
|
35 |
+
'record_type', 'record_type',
|
36 |
+
'enum("order","gift","coupon","cash","admin") CHARACTER SET utf8 NOT NULL'
|
37 |
+
);
|
38 |
+
|
39 |
+
$installer->endSetup();
|
app/code/community/Auguria/Sponsorship/sql/sponsorship_setup/mysql4-upgrade-0.1.6-0.1.7.php
ADDED
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* @category Auguria
|
4 |
+
* @package Auguria_Sponsorship
|
5 |
+
* @author Auguria
|
6 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
7 |
+
*/
|
8 |
+
$installer = $this;
|
9 |
+
|
10 |
+
$installer->startSetup();
|
11 |
+
|
12 |
+
$installer->run("
|
13 |
+
ALTER TABLE {$this->getTable('sponsorship')} DROP COLUMN `status`;
|
14 |
+
ALTER TABLE {$this->getTable('sponsorship')} DROP COLUMN `created_time`;
|
15 |
+
ALTER TABLE {$this->getTable('sponsorship')} CHANGE `update_time` `datetime` datetime NULL;
|
16 |
+
");
|
17 |
+
|
18 |
+
$installer->endSetup();
|
app/code/community/Auguria/Sponsorship/sql/sponsorship_setup/mysql4-upgrade-0.1.7-0.1.8.php
ADDED
@@ -0,0 +1,49 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* @category Auguria
|
4 |
+
* @package Auguria_Sponsorship
|
5 |
+
* @author Auguria
|
6 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
7 |
+
*/
|
8 |
+
$setup = new Mage_Sales_Model_Mysql4_Setup('core_setup');
|
9 |
+
$setup->startSetup();
|
10 |
+
|
11 |
+
$setup->addAttribute('quote_item', 'cart_fidelity_points', array(
|
12 |
+
'type' => 'decimal',
|
13 |
+
'backend' => '',
|
14 |
+
'frontend' => '',
|
15 |
+
'label' => 'Points Fidélité',
|
16 |
+
'input' => 'text',
|
17 |
+
'class' => '',
|
18 |
+
'source' => '',
|
19 |
+
'visible' => true,
|
20 |
+
'required' => false,
|
21 |
+
'user_defined' => false,
|
22 |
+
'default' => '',
|
23 |
+
'searchable' => false,
|
24 |
+
'filterable' => false,
|
25 |
+
'comparable' => false,
|
26 |
+
'visible_on_front' => false,
|
27 |
+
'unique' => false,
|
28 |
+
));
|
29 |
+
|
30 |
+
$setup->addAttribute('quote_item', 'cart_sponsor_points', array(
|
31 |
+
'type' => 'decimal',
|
32 |
+
'backend' => '',
|
33 |
+
'frontend' => '',
|
34 |
+
'label' => 'Points Parrainage',
|
35 |
+
'input' => 'text',
|
36 |
+
'class' => '',
|
37 |
+
'source' => '',
|
38 |
+
'visible' => true,
|
39 |
+
'required' => false,
|
40 |
+
'user_defined' => false,
|
41 |
+
'default' => '',
|
42 |
+
'searchable' => false,
|
43 |
+
'filterable' => false,
|
44 |
+
'comparable' => false,
|
45 |
+
'visible_on_front' => false,
|
46 |
+
'unique' => false,
|
47 |
+
));
|
48 |
+
|
49 |
+
$setup->endSetup();
|
app/code/community/Auguria/Sponsorship/sql/sponsorship_setup/mysql4-upgrade-0.1.8-0.1.9.php
ADDED
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* @category Auguria
|
4 |
+
* @package Auguria_Sponsorship
|
5 |
+
* @author Auguria
|
6 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
7 |
+
*/
|
8 |
+
$installer = $this;
|
9 |
+
|
10 |
+
$installer->startSetup();
|
11 |
+
|
12 |
+
$installer->run("
|
13 |
+
ALTER TABLE {$this->getTable('sponsorship')} ADD COLUMN `message` text;
|
14 |
+
ALTER TABLE {$this->getTable('sponsorship')} ADD COLUMN `parent_mail` varchar(255);
|
15 |
+
ALTER TABLE {$this->getTable('sponsorship')} ADD COLUMN `parent_name` varchar(255);
|
16 |
+
ALTER TABLE {$this->getTable('sponsorship')} ADD COLUMN `subject` varchar(255);
|
17 |
+
ALTER TABLE {$this->getTable('sponsorship')} ADD COLUMN `datetime_boost` datetime;
|
18 |
+
|
19 |
+
UPDATE {$this->getTable('sponsorship')} SET `datetime_boost` = `datetime` WHERE ISNULL(`datetime_boost`);
|
20 |
+
");
|
21 |
+
|
22 |
+
$installer->endSetup();
|
app/code/community/Auguria/Sponsorship/sql/sponsorship_setup/mysql4-upgrade-0.1.9-0.1.10.php
ADDED
@@ -0,0 +1,30 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* @category Auguria
|
4 |
+
* @package Auguria_Sponsorship
|
5 |
+
* @author Auguria
|
6 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
7 |
+
*/
|
8 |
+
$setup = new Mage_Eav_Model_Entity_Setup('core_setup');
|
9 |
+
$setup->startSetup();
|
10 |
+
|
11 |
+
$setup->addAttribute('customer', 'special_rate', array(
|
12 |
+
'type' => 'int',
|
13 |
+
'backend' => '',
|
14 |
+
'frontend' => '',
|
15 |
+
'label' => 'Special Rate',
|
16 |
+
'input' => 'text',
|
17 |
+
'class' => '',
|
18 |
+
'source' => '',
|
19 |
+
'visible' => true,
|
20 |
+
'required' => false,
|
21 |
+
'user_defined' => false,
|
22 |
+
'default' => '',
|
23 |
+
'searchable' => false,
|
24 |
+
'filterable' => false,
|
25 |
+
'comparable' => false,
|
26 |
+
'visible_on_front' => false,
|
27 |
+
'unique' => false,
|
28 |
+
));
|
29 |
+
|
30 |
+
$setup->endSetup();
|
app/design/adminhtml/default/default/layout/sponsorship.xml
ADDED
@@ -0,0 +1,26 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<!--
|
3 |
+
/**
|
4 |
+
* @category Auguria
|
5 |
+
* @package Auguria_Sponsorship
|
6 |
+
* @author Auguria
|
7 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
8 |
+
*/
|
9 |
+
-->
|
10 |
+
<layout version="0.1.0">
|
11 |
+
<sponsorship_adminhtml_sponsorship_index>
|
12 |
+
<reference name="content">
|
13 |
+
<block type="sponsorship/adminhtml_sponsorship" name="sponsorship" />
|
14 |
+
</reference>
|
15 |
+
</sponsorship_adminhtml_sponsorship_index>
|
16 |
+
<sponsorship_adminhtml_link_index>
|
17 |
+
<reference name="content">
|
18 |
+
<block type="sponsorship/adminhtml_link" name="link" />
|
19 |
+
</reference>
|
20 |
+
</sponsorship_adminhtml_link_index>
|
21 |
+
<sponsorship_adminhtml_change_index>
|
22 |
+
<reference name="content">
|
23 |
+
<block type="sponsorship/adminhtml_change" name="change" />
|
24 |
+
</reference>
|
25 |
+
</sponsorship_adminhtml_change_index>
|
26 |
+
</layout>
|
app/design/frontend/default/default/layout/sponsorship.xml
ADDED
@@ -0,0 +1,122 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<!--
|
3 |
+
/**
|
4 |
+
* @category Auguria
|
5 |
+
* @package Auguria_Sponsorship
|
6 |
+
* @author Auguria
|
7 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
8 |
+
*/
|
9 |
+
-->
|
10 |
+
<layout version="0.1.0">
|
11 |
+
<!-- Déclaration du template de l'index -->
|
12 |
+
<sponsorship_index_index>
|
13 |
+
<update handle="customer_account"/>
|
14 |
+
<reference name="content">
|
15 |
+
<block type="sponsorship/sponsorship" name="sponsorship" template="sponsorship/sponsorship.phtml" />
|
16 |
+
</reference>
|
17 |
+
</sponsorship_index_index>
|
18 |
+
|
19 |
+
<!-- Déclaration du block détail des points fidélité -->
|
20 |
+
<sponsorship_fidelitypoints_index>
|
21 |
+
<update handle="customer_account"/>
|
22 |
+
<!-- Ajout du css pour table_orderer -->
|
23 |
+
<reference name="head">
|
24 |
+
<action method="addCss">
|
25 |
+
<link>css/tableorderer.css</link>
|
26 |
+
</action>
|
27 |
+
<action method="addJs">
|
28 |
+
<link>tableorderer/table_orderer.js</link>
|
29 |
+
</action>
|
30 |
+
</reference>
|
31 |
+
<reference name="content">
|
32 |
+
<block type="sponsorship/customer_account_pointsDetail" name="sponsorship_customer_pointsdetail" template="sponsorship/customer/account/fidelitypointsdetail.phtml"/>
|
33 |
+
</reference>
|
34 |
+
</sponsorship_fidelitypoints_index>
|
35 |
+
|
36 |
+
<!-- Déclaration du block détail des points parrainage -->
|
37 |
+
<sponsorship_sponsorpoints_index>
|
38 |
+
<update handle="customer_account"/>
|
39 |
+
<!-- Ajout du css pour table_orderer -->
|
40 |
+
<reference name="head">
|
41 |
+
<action method="addCss">
|
42 |
+
<link>css/tableorderer.css</link>
|
43 |
+
</action>
|
44 |
+
<action method="addJs">
|
45 |
+
<link>tableorderer/table_orderer.js</link>
|
46 |
+
</action>
|
47 |
+
</reference>
|
48 |
+
<reference name="content">
|
49 |
+
<block type="sponsorship/customer_account_pointsDetail" name="sponsorship_customer_pointsdetail" template="sponsorship/customer/account/sponsorpointsdetail.phtml"/>
|
50 |
+
</reference>
|
51 |
+
</sponsorship_sponsorpoints_index>
|
52 |
+
|
53 |
+
<!-- Déclaration du block pour la relance des filleuls -->
|
54 |
+
<sponsorship_boost_index>
|
55 |
+
<update handle="customer_account"/>
|
56 |
+
<reference name="content">
|
57 |
+
<block type="sponsorship/customer_form_boost" name="sponsorship_customer_boost" template="sponsorship/customer/form/boost.phtml"/>
|
58 |
+
</reference>
|
59 |
+
</sponsorship_boost_index>
|
60 |
+
|
61 |
+
<!-- Déclaration du block d'échange des points -->
|
62 |
+
<sponsorship_fidelitypoints_change>
|
63 |
+
<update handle="customer_account"/>
|
64 |
+
<reference name="content">
|
65 |
+
<block type="sponsorship/customer_form_pointsChange" name="sponsorship_customer_pointschange" template="sponsorship/customer/form/pointschange.phtml"/>
|
66 |
+
</reference>
|
67 |
+
<reference name="sponsorship_customer_pointschange">
|
68 |
+
<block type="sponsorship/customer_form_pointsChange" name="sponsorship_customer_pointschange_cash" as="cash" template="sponsorship/customer/form/pointschange/pointschange_cash.phtml"/>
|
69 |
+
<block type="sponsorship/customer_form_pointsChange" name="sponsorship_customer_pointschange_coupon" as="coupon" template="sponsorship/customer/form/pointschange/pointschange_coupon.phtml"/>
|
70 |
+
<block type="sponsorship/customer_form_pointsChange" name="sponsorship_customer_pointschange_gift" as="gift" template="sponsorship/customer/form/pointschange/pointschange_gift.phtml"/>
|
71 |
+
</reference>
|
72 |
+
</sponsorship_fidelitypoints_change>
|
73 |
+
<sponsorship_sponsorpoints_change>
|
74 |
+
<update handle="customer_account"/>
|
75 |
+
<reference name="content">
|
76 |
+
<block type="sponsorship/customer_form_pointsChange" name="sponsorship_customer_pointschange" template="sponsorship/customer/form/pointschange.phtml"/>
|
77 |
+
</reference>
|
78 |
+
<reference name="sponsorship_customer_pointschange">
|
79 |
+
<block type="sponsorship/customer_form_pointsChange" name="sponsorship_customer_pointschange_cash" as="cash" template="sponsorship/customer/form/pointschange/pointschange_cash.phtml"/>
|
80 |
+
<block type="sponsorship/customer_form_pointsChange" name="sponsorship_customer_pointschange_coupon" as="coupon" template="sponsorship/customer/form/pointschange/pointschange_coupon.phtml"/>
|
81 |
+
<block type="sponsorship/customer_form_pointsChange" name="sponsorship_customer_pointschange_gift" as="gift" template="sponsorship/customer/form/pointschange/pointschange_gift.phtml"/>
|
82 |
+
</reference>
|
83 |
+
</sponsorship_sponsorpoints_change>
|
84 |
+
|
85 |
+
<!-- Remplacement de dashboard.phtml pour ajouter un block
|
86 |
+
Déclaration d'un block supplémentaire -->
|
87 |
+
<customer_account_index>
|
88 |
+
<reference name="customer_account_dashboard">
|
89 |
+
<action method="setTemplate">
|
90 |
+
<template>sponsorship/customer/account/dashboard.phtml</template>
|
91 |
+
</action>
|
92 |
+
<block type="sponsorship/customer_account_pointsDetail" name="customer_account_points" as="fidelity_points" template="sponsorship/customer/account/dashboard/fidelity_points.phtml"/>
|
93 |
+
<block type="sponsorship/customer_account_pointsDetail" name="customer_account_points" as="sponsor_points" template="sponsorship/customer/account/dashboard/sponsor_points.phtml"/>
|
94 |
+
</reference>
|
95 |
+
</customer_account_index>
|
96 |
+
|
97 |
+
<!-- Remplacement de edit.phtml pour ajout champ Iban dans les informations du compte-->
|
98 |
+
<customer_account_edit>
|
99 |
+
<reference name="customer_edit">
|
100 |
+
<action method="setTemplate">
|
101 |
+
<template>sponsorship/customer/form/edit.phtml</template>
|
102 |
+
</action>
|
103 |
+
</reference>
|
104 |
+
</customer_account_edit>
|
105 |
+
|
106 |
+
<!-- Ajout d'un lien vers le détail des points -->
|
107 |
+
<customer_account>
|
108 |
+
<reference name="customer_account_navigation">
|
109 |
+
<action ifconfig="sponsorship/fidelity/fidelity_enabled" method="addLink" translate="label" module="sponsorship"><name>fidelity_points</name><path>sponsorship/fidelitypoints/</path><label>Fidélité</label></action>
|
110 |
+
<action ifconfig="sponsorship/sponsor/sponsor_enabled" method="addLink" translate="label" module="sponsorship"><name>sponsor_points</name><path>sponsorship/sponsorpoints/</path><label>Parrainage</label></action>
|
111 |
+
</reference>
|
112 |
+
</customer_account>
|
113 |
+
|
114 |
+
<!-- Remplacement de register.phtml pour afficher email de la session -->
|
115 |
+
<customer_account_create>
|
116 |
+
<reference name="customer_form_register">
|
117 |
+
<action method="setTemplate">
|
118 |
+
<template>sponsorship/customer/form/register.phtml</template>
|
119 |
+
</action>
|
120 |
+
</reference>
|
121 |
+
</customer_account_create>
|
122 |
+
</layout>
|
app/design/frontend/default/default/template/sponsorship/customer/account/dashboard.phtml
ADDED
@@ -0,0 +1,53 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<!--
|
2 |
+
/**
|
3 |
+
* @category Auguria
|
4 |
+
* @package Auguria_Sponsorship
|
5 |
+
* @author Auguria
|
6 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
7 |
+
*/
|
8 |
+
-->
|
9 |
+
<div class="dashboard">
|
10 |
+
<div class="page-title">
|
11 |
+
<h1><?php echo $this->__('My Dashboard') ?></h1>
|
12 |
+
</div>
|
13 |
+
<?php echo $this->getMessagesBlock()->getGroupedHtml() ?>
|
14 |
+
<?php echo $this->getChildHtml('hello') ?>
|
15 |
+
<?php echo $this->getChildHtml('top') ?>
|
16 |
+
<div class="box-account box-info">
|
17 |
+
<div class="box-head">
|
18 |
+
<h2><?php echo $this->__('Account Information') ?></h2>
|
19 |
+
</div>
|
20 |
+
<?php echo $this->getChildHtml('info') ?>
|
21 |
+
<?php echo $this->getChildHtml('address') ?>
|
22 |
+
</div>
|
23 |
+
<?php
|
24 |
+
$sponsorEnabled = Mage::getStoreConfig('sponsorship/sponsor/sponsor_enabled');
|
25 |
+
$fidelityEnabled = Mage::getStoreConfig('sponsorship/fidelity/fidelity_enabled');
|
26 |
+
if ($sponsorEnabled):?>
|
27 |
+
<div class="box-account box-info">
|
28 |
+
<div class="box-head">
|
29 |
+
<h2><?php echo $this->__('Sponsorship'); ?></h2>
|
30 |
+
<a href="<?php echo $this->getUrl('sponsorship/sponsorpoints') ?>"><?php echo $this->__('Details')?></a>
|
31 |
+
</div>
|
32 |
+
<?php
|
33 |
+
echo $this->getChildHtml('sponsor_points');
|
34 |
+
?>
|
35 |
+
</div>
|
36 |
+
<?php
|
37 |
+
endif;
|
38 |
+
if ($fidelityEnabled):?>
|
39 |
+
<div class="box-account box-info">
|
40 |
+
<div class="box-head">
|
41 |
+
<h2><?php echo $this->__('Fidelity'); ?></h2>
|
42 |
+
<a href="<?php echo $this->getUrl('sponsorship/fidelitypoints') ?>"><?php echo $this->__('Details')?></a>
|
43 |
+
</div>
|
44 |
+
<?php
|
45 |
+
echo $this->getChildHtml('fidelity_points');
|
46 |
+
?>
|
47 |
+
</div>
|
48 |
+
<?php
|
49 |
+
endif;
|
50 |
+
?>
|
51 |
+
<?php echo $this->getChildHtml('info1') ?>
|
52 |
+
<?php echo $this->getChildHtml('info2') ?>
|
53 |
+
</div>
|
app/design/frontend/default/default/template/sponsorship/customer/account/dashboard/fidelity_points.phtml
ADDED
@@ -0,0 +1,17 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<!--
|
2 |
+
/**
|
3 |
+
* @category Auguria
|
4 |
+
* @package Auguria_Sponsorship
|
5 |
+
* @author Auguria
|
6 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
7 |
+
*/
|
8 |
+
-->
|
9 |
+
<?php
|
10 |
+
$customerId = $this->getUserId();
|
11 |
+
$customer = Mage::getModel('customer/customer')->load($customerId);
|
12 |
+
|
13 |
+
?>
|
14 |
+
<?php if (Mage::getStoreConfig('sponsorship/fidelity/fidelity_enabled')):?>
|
15 |
+
<?php echo $this->__('Fidelity points:') ?> <?php echo floor($customer->getFidelityPoints()); ?>
|
16 |
+
<br/>
|
17 |
+
<?php endif;?>
|
app/design/frontend/default/default/template/sponsorship/customer/account/dashboard/sponsor_points.phtml
ADDED
@@ -0,0 +1,23 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<!--
|
2 |
+
/**
|
3 |
+
* @category Auguria
|
4 |
+
* @package Auguria_Sponsorship
|
5 |
+
* @author Auguria
|
6 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
7 |
+
*/
|
8 |
+
-->
|
9 |
+
<?php
|
10 |
+
$customerId = $this->getUserId();
|
11 |
+
$customer = Mage::getModel('customer/customer')->load($customerId);
|
12 |
+
$nbSponsor = $this->getNbParrainages ($customerId);
|
13 |
+
?>
|
14 |
+
<?php if (Mage::getStoreConfig('sponsorship/sponsor/sponsor_enabled')):?>
|
15 |
+
<?php echo $this->__('Sponsorship points:') ?> <?php echo floor($customer->getSponsorPoints()); ?>
|
16 |
+
<br/>
|
17 |
+
<?php echo $this->__('Active godsons:') ?> <?php echo $nbSponsor; ?>
|
18 |
+
<br/>
|
19 |
+
<a href="<?php echo $this->getUrl('sponsorship_info') ?>"><?php echo $this->__('Principles of Sponsorship')?></a>
|
20 |
+
<br/>
|
21 |
+
<a href="<?php echo $this->getUrl('sponsorship') ?>"><?php echo $this->__('Sponsor friends')?></a>
|
22 |
+
<br/>
|
23 |
+
<?php endif;?>
|
app/design/frontend/default/default/template/sponsorship/customer/account/fidelitypointsdetail.phtml
ADDED
@@ -0,0 +1,167 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<!--
|
2 |
+
/**
|
3 |
+
* @category Auguria
|
4 |
+
* @package Auguria_Sponsorship
|
5 |
+
* @author Auguria
|
6 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
7 |
+
*/
|
8 |
+
-->
|
9 |
+
<?php
|
10 |
+
//initialisation des intitulés pour table orderer
|
11 |
+
$msgs = "{loading: '".$this->__("loading")
|
12 |
+
."',emptyResults: '".$this->__("emptyResults")
|
13 |
+
."',errorURL: '".$this->__("errorURL")
|
14 |
+
."',errorData: '".$this->__("errorData")
|
15 |
+
."',searchLabel: '".$this->__("searchLabel")
|
16 |
+
."',filterLabel: '".$this->__("filterLabel")
|
17 |
+
."',paginationOf: '".$this->__("paginationOf")
|
18 |
+
."',paginationPages: '".$this->__("paginationPages")
|
19 |
+
."',paginationFirst: '".$this->__("paginationFirst")
|
20 |
+
."',paginationPrev: '".$this->__("paginationPrev")
|
21 |
+
."',paginationNext: '".$this->__("paginationNext")
|
22 |
+
."',paginationLast: '".$this->__("paginationLast")."'}";
|
23 |
+
?>
|
24 |
+
<div class="std">
|
25 |
+
<div class="page-title">
|
26 |
+
<h1>
|
27 |
+
<?php echo $this->__('Fidelity points'); ?>
|
28 |
+
</h1>
|
29 |
+
</div>
|
30 |
+
<?php echo $this->getMessagesBlock()->getGroupedHtml(); ?>
|
31 |
+
|
32 |
+
<?php if ($this->getFidelityEnabledConfig ()):
|
33 |
+
|
34 |
+
//si il y eu des commandes
|
35 |
+
$_commandes = $this->getCommandes();
|
36 |
+
if ($_commandes):?>
|
37 |
+
|
38 |
+
<h2 class="title"><?php echo $this->__('Your lastest orders') ?></h2>
|
39 |
+
<div id="last-orders-table"></div>
|
40 |
+
|
41 |
+
<script type="text/javascript">
|
42 |
+
lastOrdersCols = ['<?php echo $this->__("Identifier");
|
43 |
+
?>','<?php echo $this->__("Date");
|
44 |
+
?>','<?php echo $this->__("Amount");
|
45 |
+
?>','<?php echo $this->__("Winning"); ?>'];
|
46 |
+
lastOrders = new Array(
|
47 |
+
<?php
|
48 |
+
$nb = count($_commandes);
|
49 |
+
$i = 1;
|
50 |
+
foreach ($_commandes as $_commande):
|
51 |
+
|
52 |
+
echo $this->__('{"numero": "%s",',$_commande['increment_id']);
|
53 |
+
echo $this->__('"date": "%s",',$this->formatDate($_commande['created_at']));
|
54 |
+
echo $this->__('"montant": "%01.2f",',$_commande['grand_total']);
|
55 |
+
echo $this->__('"points": "%d"}',$this->getOrderFidelityPoints($_commande['entity_id']));
|
56 |
+
if ($i != $nb)
|
57 |
+
{
|
58 |
+
echo ",
|
59 |
+
";
|
60 |
+
}
|
61 |
+
$i++;
|
62 |
+
endforeach;
|
63 |
+
?>
|
64 |
+
);
|
65 |
+
new TableOrderer('last-orders-table',{data : lastOrders, cols : lastOrdersCols},<?php echo $this->__($msgs); ?>);
|
66 |
+
</script>
|
67 |
+
<br/>
|
68 |
+
<?php endif; //fin de la vérification qu'il y a eu des commandes ?>
|
69 |
+
|
70 |
+
<h2><?php echo $this->__('Use of your fidelity points') ?></h2>
|
71 |
+
<div>
|
72 |
+
<?php
|
73 |
+
echo $this->__('Fidelity balance:');
|
74 |
+
$fPoints = floor($this->getFidelityPoints());
|
75 |
+
echo " ".$fPoints;
|
76 |
+
?>
|
77 |
+
</div>
|
78 |
+
<!--Liste des échanges réalisés-->
|
79 |
+
|
80 |
+
<?php if ($this->hasChange('fidelity')): //Début vérification qu'il y a eu des échanges'?>
|
81 |
+
<div>
|
82 |
+
<?php echo $this->__("Your points exchanges:") ?>
|
83 |
+
</div>
|
84 |
+
|
85 |
+
<div id="fidelity-change-table"></div>
|
86 |
+
|
87 |
+
<script type="text/javascript">
|
88 |
+
fidelityChangeCols = ['<?php echo $this->__("Type");
|
89 |
+
?>','<?php echo $this->__("Date");
|
90 |
+
?>','<?php echo $this->__("Points");
|
91 |
+
?>','<?php echo $this->__("Value"); ?>'];
|
92 |
+
fidelityChange = new Array(
|
93 |
+
<?php
|
94 |
+
$changes = $this->getChanges('fidelity');
|
95 |
+
$nb = count($changes);
|
96 |
+
$i = 1;
|
97 |
+
foreach ($changes as $change):
|
98 |
+
|
99 |
+
echo $this->__('{"type": "%s",',$change->getType());
|
100 |
+
echo $this->__('"date": "%s",',$this->formatDate($change->getDatetime()));
|
101 |
+
echo $this->__('"points": "%d",',$change->getPoints());
|
102 |
+
echo $this->__('"valeur": "%.2f"}',$change->getValue());
|
103 |
+
if ($i != $nb)
|
104 |
+
{
|
105 |
+
echo ",
|
106 |
+
";
|
107 |
+
}
|
108 |
+
$i++;
|
109 |
+
endforeach;
|
110 |
+
?>
|
111 |
+
);
|
112 |
+
new TableOrderer('fidelity-change-table',{data : fidelityChange, cols : fidelityChangeCols, filter:'bottom', paginate:'top', pageCount:5},<?php echo $this->__($msgs); ?>);
|
113 |
+
</script>
|
114 |
+
<?php endif; //fin de vérification qu'il y a eu des échanges fidélité ?>
|
115 |
+
<!--Liste des échanges réalisés-->
|
116 |
+
<?php if ($fPoints>0): // si le solde de points fidélité est >0?>
|
117 |
+
<?php if ($this->isFidelityChangeEnabled()):?>
|
118 |
+
<div>
|
119 |
+
<?php echo $this->__('Change your points into:');?>
|
120 |
+
<ul class="disc">
|
121 |
+
<?php if ($this->getFidelityCashConfig()):?>
|
122 |
+
<li>
|
123 |
+
<a href="<?php echo Mage::getUrl('*/*/change', Array('module'=>'fidelity','type'=>'cash')) ?>"><?php echo $this->__('Cash') ?></a>
|
124 |
+
</li>
|
125 |
+
<?php endif;?>
|
126 |
+
<?php if ($this->getFidelityCouponConfig()):?>
|
127 |
+
<li>
|
128 |
+
<a href="<?php echo Mage::getUrl('*/*/change', Array('module'=>'fidelity','type'=>'coupon')) ?>"><?php echo $this->__('Vouchers') ?></a>
|
129 |
+
</li>
|
130 |
+
<?php endif;?>
|
131 |
+
<?php if ($this->getFidelityGiftConfig()):?>
|
132 |
+
<li>
|
133 |
+
<a href="<?php echo Mage::getUrl('*/*/change', Array('module'=>'fidelity','type'=>'gift')) ?>"><?php echo $this->__('Gifts') ?></a>
|
134 |
+
</li>
|
135 |
+
<?php endif;?>
|
136 |
+
</ul>
|
137 |
+
</div>
|
138 |
+
<?php endif; //change actif?>
|
139 |
+
<?php else: //si le solde des poinst n'est pas supérieur à 0?>
|
140 |
+
<?php if ($this->isFidelityChangeEnabled()):?>
|
141 |
+
<div>
|
142 |
+
<?php echo $this->__('Once you will have points, you can change them into:');?>
|
143 |
+
<ul class="disc">
|
144 |
+
<?php if ($this->getFidelityCashConfig()):?>
|
145 |
+
<li>
|
146 |
+
<?php echo $this->__('Cash') ?>
|
147 |
+
</li>
|
148 |
+
<?php endif;?>
|
149 |
+
<?php if ($this->getFidelityCouponConfig()):?>
|
150 |
+
<li>
|
151 |
+
<?php echo $this->__('Vouchers') ?>
|
152 |
+
</li>
|
153 |
+
<?php endif;?>
|
154 |
+
<?php if ($this->getFidelityGiftConfig()):?>
|
155 |
+
<li>
|
156 |
+
<?php echo $this->__('Gifts') ?>
|
157 |
+
</li>
|
158 |
+
<?php endif;?>
|
159 |
+
</ul>
|
160 |
+
</div>
|
161 |
+
<?php endif;//fidelity change enable ?>
|
162 |
+
<?php endif; //fin de la vérification du solde des points fidélité ?>
|
163 |
+
<?php endif; ?>
|
164 |
+
<div class="buttons-set">
|
165 |
+
<p class="back-link"><a href="<?php echo $this->getBackUrl() ?>"><small>« </small><?php echo $this->__('Back') ?></a></p>
|
166 |
+
</div>
|
167 |
+
</div>
|
app/design/frontend/default/default/template/sponsorship/customer/account/sponsorpointsdetail.phtml
ADDED
@@ -0,0 +1,257 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<!--
|
2 |
+
/**
|
3 |
+
* @category Auguria
|
4 |
+
* @package Auguria_Sponsorship
|
5 |
+
* @author Auguria
|
6 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
7 |
+
*/
|
8 |
+
-->
|
9 |
+
<?php
|
10 |
+
//initialisation des intitulés pour table orderer
|
11 |
+
$msgs = "{loading: '".$this->__("loading")
|
12 |
+
."',emptyResults: '".$this->__("emptyResults")
|
13 |
+
."',errorURL: '".$this->__("errorURL")
|
14 |
+
."',errorData: '".$this->__("errorData")
|
15 |
+
."',searchLabel: '".$this->__("searchLabel")
|
16 |
+
."',filterLabel: '".$this->__("filterLabel")
|
17 |
+
."',paginationOf: '".$this->__("paginationOf")
|
18 |
+
."',paginationPages: '".$this->__("paginationPages")
|
19 |
+
."',paginationFirst: '".$this->__("paginationFirst")
|
20 |
+
."',paginationPrev: '".$this->__("paginationPrev")
|
21 |
+
."',paginationNext: '".$this->__("paginationNext")
|
22 |
+
."',paginationLast: '".$this->__("paginationLast")."'}";
|
23 |
+
?>
|
24 |
+
<div class="std">
|
25 |
+
<div class="page-title">
|
26 |
+
<h1>
|
27 |
+
<?php echo $this->__('Sponsorship'); ?>
|
28 |
+
</h1>
|
29 |
+
</div>
|
30 |
+
<?php echo $this->getMessagesBlock()->getGroupedHtml() ?>
|
31 |
+
<?php if ($this->getSponsorEnabledConfig ())://si le module parrainage est actif : affichage ?>
|
32 |
+
<p>
|
33 |
+
<a href="<?php echo $this->getUrl('sponsorship_info') ?>"><?php echo $this->__('Principles of Sponsorship')?></a>
|
34 |
+
</p>
|
35 |
+
<p>
|
36 |
+
<a href="<?php echo $this->getUrl('sponsorship') ?>"><?php echo $this->__('Sponsor friends')?></a>
|
37 |
+
</p>
|
38 |
+
<?php
|
39 |
+
/**
|
40 |
+
*
|
41 |
+
* Invistations
|
42 |
+
*/
|
43 |
+
?>
|
44 |
+
<br/>
|
45 |
+
<h2 class="title"><?php echo $this->__('Your invitations') ?></h2>
|
46 |
+
<?php //si l'utilisateur a des invitations en cours
|
47 |
+
$invits = $this->getInvits();
|
48 |
+
if ($invits):
|
49 |
+
?>
|
50 |
+
|
51 |
+
|
52 |
+
<div id="invit-table"></div>
|
53 |
+
|
54 |
+
<script type="text/javascript">
|
55 |
+
//<![CDATA[
|
56 |
+
invitsCols = ['<?php echo $this->__("Guest name");
|
57 |
+
?>','<?php echo $this->__("Guest mail");
|
58 |
+
?>','<?php echo $this->__("Date first invitation");
|
59 |
+
?>','<?php echo $this->__("Date last mail");
|
60 |
+
?>','<?php echo $this->__("Recall");
|
61 |
+
?>'];
|
62 |
+
invits = new Array(
|
63 |
+
<?php
|
64 |
+
$nb = count($invits);
|
65 |
+
$i = 1;
|
66 |
+
foreach ($invits as $invit):
|
67 |
+
|
68 |
+
echo $this->__('{"invits_name": "%s",',$invit["child_firstname"]." ".$invit["child_lastname"]);
|
69 |
+
echo $this->__('"invits_email": "%s",',$invit["child_mail"]);
|
70 |
+
echo $this->__('"invits_first_date": "%s",',$this->formatDate($invit["datetime"]));
|
71 |
+
echo $this->__('"invits_last_mail": "%s",',$this->formatDate($invit["datetime_boost"]));
|
72 |
+
echo $this->__('"relance":"%s"}',"<a href='".$this->getUrl("sponsorship/boost",array("sponsorship_id"=>$invit["sponsorship_id"]))."'>".$this->__("Recall")."</a>");
|
73 |
+
if ($i != $nb)
|
74 |
+
{
|
75 |
+
echo ",
|
76 |
+
";
|
77 |
+
}
|
78 |
+
$i++;
|
79 |
+
endforeach;
|
80 |
+
?>
|
81 |
+
);
|
82 |
+
invitsTable = new TableOrderer('invit-table',{data : invits, cols : invitsCols, filter:'bottom', paginate:'top', pageCount:5, unsortedColumn:['relance']},<?php echo $this->__($msgs); ?>);
|
83 |
+
//]]>
|
84 |
+
</script>
|
85 |
+
<?php else : ?>
|
86 |
+
<div>
|
87 |
+
<?php echo $this->__("You do not have yet send invit."); ?>
|
88 |
+
</div>
|
89 |
+
<?php endif; //fin de vérifivcation invitations en cours?>
|
90 |
+
|
91 |
+
<?php
|
92 |
+
/**
|
93 |
+
*
|
94 |
+
* Filleuls
|
95 |
+
*/
|
96 |
+
?>
|
97 |
+
<br/>
|
98 |
+
<h2 class="title"><?php echo $this->__('Your godsons') ?></h2>
|
99 |
+
<?php $_parrainages = $this->getParrainages();
|
100 |
+
if ($_parrainages): //si l'utilisateur a déjà parrainé?>
|
101 |
+
|
102 |
+
|
103 |
+
<div id="sponsor-table"></div>
|
104 |
+
|
105 |
+
<script type="text/javascript">
|
106 |
+
sponsorshipsCols = ['<?php echo $this->__("Godson name");
|
107 |
+
?>','<?php echo $this->__("Sponsorship date");
|
108 |
+
?>','<?php echo $this->__("Last order date");
|
109 |
+
?>','<?php echo $this->__("Winning");
|
110 |
+
?>','<?php echo $this->__("Number of sponsorships");
|
111 |
+
?>'];
|
112 |
+
sponsorships = new Array(
|
113 |
+
<?php
|
114 |
+
$nb = count($_parrainages);
|
115 |
+
$i = 1;
|
116 |
+
foreach ($_parrainages as $_parrainage):
|
117 |
+
$dateFDC ="";
|
118 |
+
if ($dateDernCde = $this->getDateDernCde ($_parrainage['entity_id'])) {
|
119 |
+
$dateFDC = $this->formatDate($dateDernCde);
|
120 |
+
}
|
121 |
+
else {
|
122 |
+
$dateFDC = "-";
|
123 |
+
}
|
124 |
+
echo $this->__('{"nom": "%s",',$_parrainage['name']);
|
125 |
+
echo $this->__('"sponsorship_date": "%s",',$this->formatDate($_parrainage['created_at']));
|
126 |
+
echo $this->__('"last_order_date": "%s",',$dateFDC);
|
127 |
+
echo $this->__('"points": "%s",',floor($this->getBranchPoints ($_parrainage['entity_id'])));
|
128 |
+
echo $this->__('"sponsorship_count":"%s"}',$this->getNbParrainages ($_parrainage['entity_id']));
|
129 |
+
if ($i != $nb)
|
130 |
+
{
|
131 |
+
echo ",
|
132 |
+
";
|
133 |
+
}
|
134 |
+
$i++;
|
135 |
+
endforeach;
|
136 |
+
?>
|
137 |
+
);
|
138 |
+
sponsorshipsTable = new TableOrderer('sponsor-table',{data : sponsorships, cols : sponsorshipsCols, filter:'bottom', paginate:'top', pageCount:5},<?php echo $this->__($msgs); ?>);
|
139 |
+
|
140 |
+
</script>
|
141 |
+
<br/>
|
142 |
+
<?php else: //si il n'a jamais parrainé déjà parrainé ?>
|
143 |
+
<div>
|
144 |
+
<?php echo $this->__("You do not have active godson."); ?>
|
145 |
+
</div>
|
146 |
+
<?php endif; //fin verificatio si il a parrainé ?>
|
147 |
+
|
148 |
+
<?php
|
149 |
+
/**
|
150 |
+
*
|
151 |
+
* Points
|
152 |
+
*/
|
153 |
+
?>
|
154 |
+
<br/>
|
155 |
+
<h2>
|
156 |
+
<?php echo $this->__('Use of your sponsorship points') ?>
|
157 |
+
</h2>
|
158 |
+
<div>
|
159 |
+
<?php
|
160 |
+
echo $this->__('Sponsorship balance:');
|
161 |
+
$sPoints = floor($this->getSponsorPoints());
|
162 |
+
echo " ".$sPoints
|
163 |
+
?>
|
164 |
+
</div>
|
165 |
+
<!--Liste des échanges réalisés-->
|
166 |
+
<div>
|
167 |
+
<?php if ($this->hasChange('sponsor')):?>
|
168 |
+
<?php
|
169 |
+
echo $this->__("Your points exchanges:");
|
170 |
+
$changes = $this->getChanges('sponsor');
|
171 |
+
?>
|
172 |
+
|
173 |
+
<div id="sponsor-change-table"></div>
|
174 |
+
|
175 |
+
<script type="text/javascript">
|
176 |
+
sponsorshipChangesCols = ['<?php echo $this->__("Type");
|
177 |
+
?>','<?php echo $this->__("Date");
|
178 |
+
?>','<?php echo $this->__("Points");
|
179 |
+
?>','<?php echo $this->__("Value");
|
180 |
+
?>'];
|
181 |
+
sponsorshipChanges = new Array(
|
182 |
+
<?php
|
183 |
+
$nb = count($changes);
|
184 |
+
$i = 1;
|
185 |
+
foreach ($changes as $change):
|
186 |
+
|
187 |
+
echo $this->__('{"type": "%s",',$change->getType());
|
188 |
+
echo $this->__('"date": "%s",',$this->formatDate($change->getDatetime()));
|
189 |
+
echo $this->__('"points": "%d",',$change->getPoints());
|
190 |
+
echo $this->__('"valeur": "%.2f"}',$change->getValue());
|
191 |
+
if ($i != $nb)
|
192 |
+
{
|
193 |
+
echo ",
|
194 |
+
";
|
195 |
+
}
|
196 |
+
$i++;
|
197 |
+
endforeach;
|
198 |
+
?>
|
199 |
+
);
|
200 |
+
new TableOrderer('sponsor-change-table',{data : sponsorshipChanges, cols : sponsorshipChangesCols, filter:'bottom', paginate:'top', pageCount:5},<?php echo $this->__($msgs); ?>);
|
201 |
+
|
202 |
+
</script>
|
203 |
+
<?php endif; ?>
|
204 |
+
</div>
|
205 |
+
<!--Liste des échanges réalisés-->
|
206 |
+
<?php if ($sPoints>0): //vérification du solde des points ?>
|
207 |
+
<?php if ($this->isSponsorChangeEnabled()): //verification change actif?>
|
208 |
+
<div>
|
209 |
+
<?php echo $this->__('Change your points into:');?>
|
210 |
+
<ul class="disc">
|
211 |
+
<?php if ($this->getSponsorCashConfig()):?>
|
212 |
+
<li>
|
213 |
+
<a href="<?php echo Mage::getUrl('*/*/change', Array('module'=>'sponsor','type'=>'cash')) ?>"><?php echo $this->__('Cash') ?></a>
|
214 |
+
</li>
|
215 |
+
<?php endif;?>
|
216 |
+
<?php if ($this->getSponsorCouponConfig()):?>
|
217 |
+
<li>
|
218 |
+
<a href="<?php echo Mage::getUrl('*/*/change', Array('module'=>'sponsor','type'=>'coupon')) ?>"><?php echo $this->__('Vouchers') ?></a>
|
219 |
+
</li>
|
220 |
+
<?php endif;?>
|
221 |
+
<?php if ($this->getSponsorGiftConfig()):?>
|
222 |
+
<li>
|
223 |
+
<a href="<?php echo Mage::getUrl('*/*/change', Array('module'=>'sponsor','type'=>'gift')) ?>"><?php echo $this->__('Gifts') ?></a>
|
224 |
+
</li>
|
225 |
+
<?php endif;?>
|
226 |
+
</ul>
|
227 |
+
</div>
|
228 |
+
<?php endif; //change actif?>
|
229 |
+
<?php else: //si il n'a pas de points?>
|
230 |
+
<?php if ($this->isSponsorChangeEnabled()):?>
|
231 |
+
<div>
|
232 |
+
<?php echo $this->__('Once you will have points, you can change them into:');?>
|
233 |
+
</div>
|
234 |
+
<ul class="disc">
|
235 |
+
<?php if ($this->getSponsorCashConfig()):?>
|
236 |
+
<li>
|
237 |
+
<?php echo $this->__('Cash') ?>
|
238 |
+
</li>
|
239 |
+
<?php endif;?>
|
240 |
+
<?php if ($this->getSponsorCouponConfig()):?>
|
241 |
+
<li>
|
242 |
+
<?php echo $this->__('Vouchers') ?>
|
243 |
+
</li>
|
244 |
+
<?php endif;?>
|
245 |
+
<?php if ($this->getSponsorGiftConfig()):?>
|
246 |
+
<li>
|
247 |
+
<?php echo $this->__('Gifts') ?>
|
248 |
+
</li>
|
249 |
+
<?php endif;?>
|
250 |
+
</ul>
|
251 |
+
<?php endif;//change enable ?>
|
252 |
+
<?php endif; //fin de vérification solde des points ?>
|
253 |
+
<?php endif; //fin module parrainage enable ?>
|
254 |
+
<div class="buttons-set">
|
255 |
+
<p class="back-link"><a href="<?php echo $this->getBackUrl() ?>"><small>« </small><?php echo $this->__('Back') ?></a></p>
|
256 |
+
</div>
|
257 |
+
</div>
|
app/design/frontend/default/default/template/sponsorship/customer/form/boost.phtml
ADDED
@@ -0,0 +1,86 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<!--
|
2 |
+
/**
|
3 |
+
* @category Auguria
|
4 |
+
* @package Auguria_Sponsorship
|
5 |
+
* @author Auguria
|
6 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
7 |
+
*/
|
8 |
+
-->
|
9 |
+
<?php
|
10 |
+
if ($invit = $this->getInvit()):
|
11 |
+
?>
|
12 |
+
<div class="std">
|
13 |
+
<div class="page-title">
|
14 |
+
<h1><?php echo $this->__('Recall %s %s', $invit->getChildFirstname(), $invit->getChildLastname()) ?></h1>
|
15 |
+
</div>
|
16 |
+
<?php echo $this->getMessagesBlock()->getGroupedHtml() ?>
|
17 |
+
<form action="<?php echo $this->getUrl('sponsorship/boost/post') ?>" method="post" id="boost">
|
18 |
+
<?php echo $this->getBlockHtml('formkey')?>
|
19 |
+
<div class="fieldset sender_options">
|
20 |
+
<h2 class="legend"><?php echo $this->__('Sender:') ?></h2>
|
21 |
+
<ul class="form-list" id="sender_options">
|
22 |
+
<li>
|
23 |
+
<div class="left">
|
24 |
+
<label for="sender_name" class="required"><em>*</em><?php echo $this->__('Name:') ?></label><br/>
|
25 |
+
<div style="width:250px"><input name="sender[name]" value="<?php echo $this->__($invit->getParentName()) ?>" title="<?php echo $this->__('Name') ?>" id="sender_name" type="text" class="input-text required-entry" style="width:250px;" /></div>
|
26 |
+
<input name="sender[id]" value="<?php echo $this->__($invit->getParentId()); ?>" id="sender_id" type="hidden"/>
|
27 |
+
<input name="sponsorship_id" value="<?php echo $this->__($invit->getSponsorshipId()); ?>" id="sponsorship_id" type="hidden"/>
|
28 |
+
</div>
|
29 |
+
<div class="right">
|
30 |
+
<label for="sender_email" class="required"><em>*</em><?php echo $this->__('Email Address:') ?></label><br/>
|
31 |
+
<div style="width:250px"><input name="sender[email]" value="<?php echo $this->__($this->getParentEmail()) ?>" title="<?php echo $this->__('Email Address') ?>" id="sender_email" type="text" class="input-text required-entry validate-email" style="width:250px;" /></div>
|
32 |
+
</div>
|
33 |
+
</li>
|
34 |
+
</ul>
|
35 |
+
</div>
|
36 |
+
<div class="fieldset recipient_options">
|
37 |
+
<h2 class="legend"><?php echo $this->__('Recipient:') ?></h2>
|
38 |
+
<ul class="form-list" id="recipient_options">
|
39 |
+
<li>
|
40 |
+
<div class="left">
|
41 |
+
<label for="recipient_email" class="required"><em>*</em><?php echo $this->__('Email Address:') ?></label><br/>
|
42 |
+
<div style="width:250px"><input name="recipient[email][]" value="<?php echo $this->__($invit->getChildMail()) ?>" title="<?php echo $this->__('Email Address') ?>" id="recipients_email" type="text" class="input-text required-entry validate-email" style="width:250px;" /></div>
|
43 |
+
<input name="recipient[firstname][]" value="<?php echo $this->__($invit->getChildFirstname()) ?>" id="recipient_firstname" type="hidden"/>
|
44 |
+
<input name="recipient[lastname][]" value="<?php echo $this->__($invit->getChildLastname()) ?>" id="recipient_lastname" type="hidden"/>
|
45 |
+
|
46 |
+
</div>
|
47 |
+
</li>
|
48 |
+
</ul>
|
49 |
+
</div>
|
50 |
+
<div class="fieldset message_options">
|
51 |
+
<h2 class="legend"><?php echo $this->__('Message:') ?></h2>
|
52 |
+
<ul class="form-list" id="message_options">
|
53 |
+
<li>
|
54 |
+
<div class="left">
|
55 |
+
<label for="message_subject" class="required"><em>*</em><?php echo $this->__('Subject:') ?></label><br/>
|
56 |
+
<div style="width:250px"><input name="message[subject]" value="<?php echo $this->__($invit->getSubject()) ?>" title="<?php echo $this->__('Subject') ?>" id="message_subject" type="text" class="input-text required-entry" style="width:250px;" /></div>
|
57 |
+
</div>
|
58 |
+
</li>
|
59 |
+
<li>
|
60 |
+
<div>
|
61 |
+
<label for="message_body" class="required"><em>*</em><?php echo $this->__('Message:') ?></label>
|
62 |
+
<textarea name="message[body]" class="input-text required-entry" id="message_body" cols="3" rows="8" style="width:100%;height:180px"><?php
|
63 |
+
echo $this->__($invit->getMessage())
|
64 |
+
?></textarea>
|
65 |
+
</div>
|
66 |
+
</li>
|
67 |
+
<li>
|
68 |
+
<div>
|
69 |
+
<label class="required"><em>*</em><?php echo $this->__("Your message will ends as follows:"); ?></label>
|
70 |
+
<br/>
|
71 |
+
<?php echo Mage::helper('sponsorship/mail')->getFooterMessage($invit->getParentId(),$invit->getChildFirstname(), $invit->getChildLastname(), $invit->getChildMail()); ?>
|
72 |
+
</div>
|
73 |
+
</li>
|
74 |
+
</ul>
|
75 |
+
</div>
|
76 |
+
<div class="buttons-set">
|
77 |
+
<p class="required"><?php echo $this->__('* Required Fields') ?></p>
|
78 |
+
<p class="back-link"><a href="<?php echo $this->getUrl('sponsorship/points') ?>"><small>« </small><?php echo $this->__('Back') ?></a></p>
|
79 |
+
<button class="button" type="submit"><span><?php echo $this->__('Send email') ?></span></button>
|
80 |
+
</div>
|
81 |
+
</form>
|
82 |
+
<script type="text/javascript">
|
83 |
+
var dataForm = new VarienForm('boost', true);
|
84 |
+
</script>
|
85 |
+
</div>
|
86 |
+
<?php endif; //fin verification qu'un filleul est envoyé par post ?>
|
app/design/frontend/default/default/template/sponsorship/customer/form/edit.phtml
ADDED
@@ -0,0 +1,120 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Magento
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the Academic Free License (AFL 3.0)
|
8 |
+
* that is bundled with this package in the file LICENSE_AFL.txt.
|
9 |
+
* It is also available through the world-wide-web at this URL:
|
10 |
+
* http://opensource.org/licenses/afl-3.0.php
|
11 |
+
* If you did not receive a copy of the license and are unable to
|
12 |
+
* obtain it through the world-wide-web, please send an email
|
13 |
+
* to license@magentocommerce.com so we can send you a copy immediately.
|
14 |
+
*
|
15 |
+
* DISCLAIMER
|
16 |
+
*
|
17 |
+
* Do not edit or add to this file if you wish to upgrade Magento to newer
|
18 |
+
* versions in the future. If you wish to customize Magento for your
|
19 |
+
* needs please refer to http://www.magentocommerce.com for more information.
|
20 |
+
*
|
21 |
+
* @category design
|
22 |
+
* @package base_default
|
23 |
+
* @copyright Copyright (c) 2009 Irubin Consulting Inc. DBA Varien (http://www.varien.com)
|
24 |
+
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
|
25 |
+
*/
|
26 |
+
?>
|
27 |
+
<div class="page-title">
|
28 |
+
<h1><?php echo $this->__('Edit Account Information') ?></h1>
|
29 |
+
</div>
|
30 |
+
<?php echo $this->getMessagesBlock()->getGroupedHtml() ?>
|
31 |
+
<form action="<?php echo $this->getUrl('customer/account/editPost') ?>" method="post" id="form-validate">
|
32 |
+
<div class="fieldset">
|
33 |
+
<?php echo $this->getBlockHtml('formkey')?>
|
34 |
+
<h2 class="legend"><?php echo $this->__('Account Information') ?></h2>
|
35 |
+
<ul class="form-list">
|
36 |
+
<li class="fields">
|
37 |
+
<?php echo $this->getLayout()->createBlock('customer/widget_name')->setObject($this->getCustomer())->toHtml() ?>
|
38 |
+
</li>
|
39 |
+
<li>
|
40 |
+
<label for="email" class="required"><em>*</em><?php echo $this->__('Email Address') ?></label>
|
41 |
+
<div class="input-box">
|
42 |
+
<input type="text" name="email" id="email" value="<?php echo $this->htmlEscape($this->getCustomer()->getEmail()) ?>" title="<?php echo $this->__('Email Address') ?>" class="input-text required-entry validate-email" />
|
43 |
+
</div>
|
44 |
+
</li>
|
45 |
+
<?php $_dob = $this->getLayout()->createBlock('customer/widget_dob') ?>
|
46 |
+
<?php if ($_dob->isEnabled()): ?>
|
47 |
+
<li><?php echo $_dob->setDate($this->getCustomer()->getDob())->toHtml() ?></li>
|
48 |
+
<?php endif ?>
|
49 |
+
<?php $_taxvat = $this->getLayout()->createBlock('customer/widget_taxvat') ?>
|
50 |
+
<?php if ($_taxvat->isEnabled()): ?>
|
51 |
+
<li><?php echo $_taxvat->setTaxvat($this->getCustomer()->getTaxvat())->toHtml() ?></li>
|
52 |
+
<?php endif ?>
|
53 |
+
<?php $_gender = $this->getLayout()->createBlock('customer/widget_gender') ?>
|
54 |
+
<?php if ($_gender->isEnabled()): ?>
|
55 |
+
<li><?php echo $_gender->setGender($this->getCustomer()->getGender())->toHtml() ?></li>
|
56 |
+
<?php endif ?>
|
57 |
+
<?php $_virement = $this->getLayout()->createBlock('sponsorship/customer_widget_virement') ?>
|
58 |
+
<?php if ($_virement->isEnabled()): ?>
|
59 |
+
<li><?php echo $_virement->setIban($this->getCustomer()->getIban())
|
60 |
+
->setSiret($this->getCustomer()->getSiret())
|
61 |
+
->toHtml(); ?></li>
|
62 |
+
<?php endif ?>
|
63 |
+
<li class="control">
|
64 |
+
<input type="checkbox" name="change_password" id="change_password" value="1" onclick="setPasswordForm(this.checked)" title="<?php echo $this->__('Change Password') ?>"<?php if($this->getCustomer()->getChangePassword()==1): ?> checked="checked"<?php endif; ?> class="checkbox" /><label for="change_password"><?php echo $this->__('Change Password') ?></label>
|
65 |
+
</li>
|
66 |
+
</ul>
|
67 |
+
</div>
|
68 |
+
<div class="fieldset" style="display:none;">
|
69 |
+
<h2 class="legend"><?php echo $this->__('Change Password') ?></h2>
|
70 |
+
<ul class="form-list">
|
71 |
+
<li>
|
72 |
+
<label for="current_password" class="required"><em>*</em><?php echo $this->__('Current Password') ?></label>
|
73 |
+
<div class="input-box">
|
74 |
+
<input type="password" title="<?php echo $this->__('Current Password') ?>" class="input-text" name="current_password" id="current_password" />
|
75 |
+
</div>
|
76 |
+
</li>
|
77 |
+
<li class="fields">
|
78 |
+
<div class="field">
|
79 |
+
<label for="password" class="required"><em>*</em><?php echo $this->__('New Password') ?></label>
|
80 |
+
<div class="input-box">
|
81 |
+
<input type="password" title="<?php echo $this->__('New Password') ?>" class="input-text validate-password" name="password" id="password" />
|
82 |
+
</div>
|
83 |
+
</div>
|
84 |
+
<div class="field">
|
85 |
+
<label for="confirmation" class="required"><em>*</em><?php echo $this->__('Confirm New Password') ?></label>
|
86 |
+
<div class="input-box">
|
87 |
+
<input type="password" title="<?php echo $this->__('Confirm New Password') ?>" class="input-text validate-cpassword" name="confirmation" id="confirmation" />
|
88 |
+
</div>
|
89 |
+
</div>
|
90 |
+
</li>
|
91 |
+
</ul>
|
92 |
+
</div>
|
93 |
+
<div class="buttons-set">
|
94 |
+
<p class="required"><?php echo $this->__('* Required Fields') ?></p>
|
95 |
+
<p class="back-link"><a href="<?php echo $this->getBackUrl() ?>"><small>« </small><?php echo $this->__('Back') ?></a></p>
|
96 |
+
<button type="submit" title="<?php echo $this->__('Save') ?>" class="button"><span><span><?php echo $this->__('Save') ?></span></span></button>
|
97 |
+
</div>
|
98 |
+
</form>
|
99 |
+
<script type="text/javascript">
|
100 |
+
//<![CDATA[
|
101 |
+
var dataForm = new VarienForm('form-validate', true);
|
102 |
+
function setPasswordForm(arg){
|
103 |
+
if(arg){
|
104 |
+
$('current_password').up(3).show();
|
105 |
+
$('current_password').addClassName('required-entry');
|
106 |
+
$('password').addClassName('required-entry');
|
107 |
+
$('confirmation').addClassName('required-entry');
|
108 |
+
|
109 |
+
}else{
|
110 |
+
$('current_password').up(3).hide();
|
111 |
+
$('current_password').removeClassName('required-entry');
|
112 |
+
$('password').removeClassName('required-entry');
|
113 |
+
$('confirmation').removeClassName('required-entry');
|
114 |
+
}
|
115 |
+
}
|
116 |
+
<?php if($this->getCustomer()->getChangePassword()): ?>
|
117 |
+
setPasswordForm(true);
|
118 |
+
<?php endif; ?>
|
119 |
+
//]]>
|
120 |
+
</script>
|
app/design/frontend/default/default/template/sponsorship/customer/form/pointschange.phtml
ADDED
@@ -0,0 +1,34 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<!--
|
2 |
+
/**
|
3 |
+
* @category Auguria
|
4 |
+
* @package Auguria_Sponsorship
|
5 |
+
* @author Auguria
|
6 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
7 |
+
*/
|
8 |
+
-->
|
9 |
+
<?php
|
10 |
+
$change = $this->getChange();
|
11 |
+
$module = $change['module'];
|
12 |
+
$type = $change['type'];
|
13 |
+
?>
|
14 |
+
<div class="std">
|
15 |
+
<div class="page-title">
|
16 |
+
<h1><?php echo $this->__('Exchange of your %s points into %s', $this->__($module), $this->__($type)) ?></h1>
|
17 |
+
</div>
|
18 |
+
<br/>
|
19 |
+
<?php echo $this->getMessagesBlock()->getGroupedHtml() ?>
|
20 |
+
<form action="<?php echo $this->getUrl('sponsorship/'.$module.'points/save') ?>" method="post" id="form-validate">
|
21 |
+
<?php echo $this->getBlockHtml('formkey')?>
|
22 |
+
<input type="hidden" name="module" id="module" value="<?php echo $module ?>"/>
|
23 |
+
<input type="hidden" name="type" id="type" value="<?php echo $type ?>"/>
|
24 |
+
<?php echo $this->getChildHtml($type) ?>
|
25 |
+
<div class="buttons-set">
|
26 |
+
<p class="required"><?php echo $this->__('* Required Fields') ?></p>
|
27 |
+
<p class="back-link"><a href="<?php echo Mage::getUrl('sponsorship/'.$module.'points') ?>"><small>« </small><?php echo $this->__('Back') ?></a></p>
|
28 |
+
<button class="button" type="submit"><span><?php echo $this->__('Validate') ?></span></button>
|
29 |
+
</div>
|
30 |
+
</form>
|
31 |
+
<script type="text/javascript">
|
32 |
+
var dataForm = new VarienForm('form-validate', true);
|
33 |
+
</script>
|
34 |
+
</div>
|
app/design/frontend/default/default/template/sponsorship/customer/form/pointschange/pointschange_cash.phtml
ADDED
@@ -0,0 +1,65 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<!--
|
2 |
+
/**
|
3 |
+
* @category Auguria
|
4 |
+
* @package Auguria_Sponsorship
|
5 |
+
* @author Auguria
|
6 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
7 |
+
*/
|
8 |
+
-->
|
9 |
+
<?php
|
10 |
+
$change = $this->getChange();
|
11 |
+
$module = $change['module'];
|
12 |
+
$Module = ucfirst($module);
|
13 |
+
$type = $change['type'];
|
14 |
+
$Type = ucfirst($type);
|
15 |
+
|
16 |
+
$getDispoPoints = 'get'.$Module.'Points';
|
17 |
+
$dPoints = $this->$getDispoPoints();
|
18 |
+
|
19 |
+
$PointsToCash = $this->getPointsToCashConfig($Module);
|
20 |
+
|
21 |
+
echo $this->__('You have %d points.',$dPoints);
|
22 |
+
|
23 |
+
|
24 |
+
|
25 |
+
?>
|
26 |
+
<ul class="form-list">
|
27 |
+
<li>
|
28 |
+
<div class="input-box">
|
29 |
+
<label for="points" class="required"><em>*</em><?php echo $this->__('Points to exchange:') ?></label><br/>
|
30 |
+
<input onChange="pointsToCash('points')" type="text" name="points" id="points" value="<?php echo $this->__('%d',$dPoints) ?>" title="<?php echo $this->__('Enter the points you want to convert.') ?>" class="required-entry input-text validate-digits"/>
|
31 |
+
</div>
|
32 |
+
</li>
|
33 |
+
<li>
|
34 |
+
<div class="input-box">
|
35 |
+
<label for="cash" class="required"><em>*</em><?php echo $this->__('Cash :') ?></label><br/>
|
36 |
+
<input onChange="pointsToCash('cash')" type="text" name="cash" id="cash" value="" title="<?php echo $this->__('Enter the cash you want.') ?>" class="required-entry input-text validate-not-negative-number"/>
|
37 |
+
</div>
|
38 |
+
</li>
|
39 |
+
</ul>
|
40 |
+
<script type="text/javascript">
|
41 |
+
var dataForm = new VarienForm('form-validate', true);
|
42 |
+
pointsToCash('points');
|
43 |
+
function pointsToCash(fieldId)
|
44 |
+
{
|
45 |
+
var points = document.getElementById('points');
|
46 |
+
var cash = document.getElementById('cash');
|
47 |
+
var taux = <?php echo $PointsToCash ?>;
|
48 |
+
if (fieldId == 'points')
|
49 |
+
{
|
50 |
+
var cashValue = points.value*taux;
|
51 |
+
cash.value = cashValue.toFixed(2);
|
52 |
+
}
|
53 |
+
else if (fieldId == 'cash')
|
54 |
+
{
|
55 |
+
var pointsValue = cash.value/taux;
|
56 |
+
points.value = pointsValue.round();
|
57 |
+
var cashValue = pointsValue.round()*taux;
|
58 |
+
cash.value = cashValue.toFixed(2);
|
59 |
+
}
|
60 |
+
}
|
61 |
+
|
62 |
+
function cashToPoint()
|
63 |
+
{
|
64 |
+
}
|
65 |
+
</script>
|
app/design/frontend/default/default/template/sponsorship/customer/form/pointschange/pointschange_coupon.phtml
ADDED
@@ -0,0 +1,59 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<!--
|
2 |
+
/**
|
3 |
+
* @category Auguria
|
4 |
+
* @package Auguria_Sponsorship
|
5 |
+
* @author Auguria
|
6 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
7 |
+
*/
|
8 |
+
-->
|
9 |
+
<?php
|
10 |
+
$change = $this->getChange();
|
11 |
+
$module = $change['module'];
|
12 |
+
$Module = ucfirst($module);
|
13 |
+
$type = $change['type'];
|
14 |
+
$Type = ucfirst($type);
|
15 |
+
|
16 |
+
$getDispoPoints = 'get'.$Module.'Points';
|
17 |
+
$dPoints = $this->$getDispoPoints();
|
18 |
+
|
19 |
+
$PointsToCash = $this->getPointsToCashConfig($Module);
|
20 |
+
|
21 |
+
echo $this->__('You have %d points.',$dPoints);
|
22 |
+
?>
|
23 |
+
<ul class="form-list">
|
24 |
+
<li>
|
25 |
+
<div class="input-box">
|
26 |
+
<label for="points" class="required"><em>*</em><?php echo $this->__('Points to exchange:') ?></label><br/>
|
27 |
+
<input onChange="pointsToCoupon('points')" type="text" name="points" id="points" value="<?php echo $this->__('%d',$dPoints) ?>" title="<?php echo $this->__('Enter the points you want to convert.') ?>" class="required-entry input-text validate-digits"/>
|
28 |
+
</div>
|
29 |
+
</li>
|
30 |
+
<li>
|
31 |
+
<div class="input-box">
|
32 |
+
<label for="coupon" class="required"><em>*</em><?php echo $this->__('Vouchers:') ?></label><br/>
|
33 |
+
<input onChange="pointsToCoupon('coupon')" type="text" name="coupon" id="coupon" value="" title="<?php echo $this->__('Indiquez la valeur du bon de réduction que vous souhaitez obtenir.') ?>" class="required-entry input-text validate-not-negative-number"/>
|
34 |
+
</div>
|
35 |
+
</li>
|
36 |
+
</ul>
|
37 |
+
<script type="text/javascript">
|
38 |
+
var dataForm = new VarienForm('form-validate', true);
|
39 |
+
pointsToCoupon('points');
|
40 |
+
function pointsToCoupon(fieldId)
|
41 |
+
{
|
42 |
+
var points = document.getElementById('points');
|
43 |
+
var coupon = document.getElementById('coupon');
|
44 |
+
var taux = <?php echo $PointsToCash ?>;
|
45 |
+
if (fieldId == 'points')
|
46 |
+
{
|
47 |
+
var cashValue = points.value*taux;
|
48 |
+
coupon.value = cashValue.toFixed(2);
|
49 |
+
}
|
50 |
+
else if (fieldId == 'coupon')
|
51 |
+
{
|
52 |
+
var pointsValue = coupon.value/taux;
|
53 |
+
points.value = pointsValue.round();
|
54 |
+
var couponValue = pointsValue.round()*taux;
|
55 |
+
coupon.value = couponValue.toFixed(2);
|
56 |
+
}
|
57 |
+
}
|
58 |
+
|
59 |
+
</script>
|
app/design/frontend/default/default/template/sponsorship/customer/form/pointschange/pointschange_gift.phtml
ADDED
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<!--
|
2 |
+
/**
|
3 |
+
* @category Auguria
|
4 |
+
* @package Auguria_Sponsorship
|
5 |
+
* @author Auguria
|
6 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
7 |
+
*/
|
8 |
+
-->
|
9 |
+
<p><?php echo $this->__('The gifts exchange is not yet implemented.') ?></p>
|
app/design/frontend/default/default/template/sponsorship/customer/form/register.phtml
ADDED
@@ -0,0 +1,174 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Magento
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the Academic Free License (AFL 3.0)
|
8 |
+
* that is bundled with this package in the file LICENSE_AFL.txt.
|
9 |
+
* It is also available through the world-wide-web at this URL:
|
10 |
+
* http://opensource.org/licenses/afl-3.0.php
|
11 |
+
* If you did not receive a copy of the license and are unable to
|
12 |
+
* obtain it through the world-wide-web, please send an email
|
13 |
+
* to license@magentocommerce.com so we can send you a copy immediately.
|
14 |
+
*
|
15 |
+
* DISCLAIMER
|
16 |
+
*
|
17 |
+
* Do not edit or add to this file if you wish to upgrade Magento to newer
|
18 |
+
* versions in the future. If you wish to customize Magento for your
|
19 |
+
* needs please refer to http://www.magentocommerce.com for more information.
|
20 |
+
*
|
21 |
+
* @category design_default
|
22 |
+
* @package Mage
|
23 |
+
* @copyright Copyright (c) 2008 Irubin Consulting Inc. DBA Varien (http://www.varien.com)
|
24 |
+
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
|
25 |
+
|
26 |
+
* @category Auguria
|
27 |
+
* @package Auguria_Sponsorship
|
28 |
+
* @author Auguria
|
29 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
30 |
+
*/
|
31 |
+
?>
|
32 |
+
<?php
|
33 |
+
/**
|
34 |
+
* Create account form template
|
35 |
+
*
|
36 |
+
* @see Mage_Customer_Block_Form_Register
|
37 |
+
*/
|
38 |
+
?>
|
39 |
+
<div class="page-head">
|
40 |
+
<h3><?php echo $this->__('Create an Account') ?></h3>
|
41 |
+
</div>
|
42 |
+
<?php echo $this->getMessagesBlock()->getGroupedHtml() ?>
|
43 |
+
<form action="<?php echo $this->getPostActionUrl() ?>" method="post" id="form-validate">
|
44 |
+
<fieldset class="group-select wide">
|
45 |
+
<input type="hidden" name="success_url" value="<?php echo $this->getSuccessUrl() ?>"/>
|
46 |
+
<input type="hidden" name="error_url" value="<?php echo $this->getErrorUrl() ?>"/>
|
47 |
+
<div class="head-alt2">
|
48 |
+
<h4 class="title"><?php echo $this->__('Personal Information') ?></h4>
|
49 |
+
</div>
|
50 |
+
<ul>
|
51 |
+
<li>
|
52 |
+
<?php echo $this->getLayout()->createBlock('customer/widget_name')->setObject($this->getFormData())->toHtml() ?>
|
53 |
+
</li>
|
54 |
+
<li>
|
55 |
+
<div class="input-box">
|
56 |
+
<label for="email_address"><?php echo $this->__('Email Address') ?> <span class="required">*</span></label><br/>
|
57 |
+
<input type="text" name="email" id="email_address" value="<?php
|
58 |
+
if ($this->htmlEscape($this->getFormData()->getEmail())=='')
|
59 |
+
{
|
60 |
+
echo $this->htmlEscape(Mage::getBlockSingleton('sponsorship/customer_widget_name')-> getInvit('email'));
|
61 |
+
}
|
62 |
+
else
|
63 |
+
{
|
64 |
+
echo $this->htmlEscape($this->getFormData()->getEmail());
|
65 |
+
}
|
66 |
+
?>" title="<?php echo $this->__('Email Address') ?>" class="validate-email required-entry input-text"/>
|
67 |
+
</div>
|
68 |
+
</li>
|
69 |
+
<?php if ($this->isNewsletterEnabled()): ?>
|
70 |
+
<li>
|
71 |
+
<input type="checkbox" name="is_subscribed" title="<?php echo $this->__('Sign Up for Newsletter') ?>" value="1" id="is_subscribed"
|
72 |
+
<?php if($this->getData('form_data')==""): ?> checked="checked"
|
73 |
+
<?php elseif ($this->getFormData()->getIsSubscribed()): ?> checked="checked"
|
74 |
+
<?php endif; ?>/>
|
75 |
+
<label for="is_subscribed"><?php echo $this->__('Sign Up for Newsletter') ?></label>
|
76 |
+
</li>
|
77 |
+
<?php endif ?>
|
78 |
+
<?php $_dob = $this->getLayout()->createBlock('customer/widget_dob') ?>
|
79 |
+
<?php if ($_dob->isEnabled()): ?>
|
80 |
+
<li><?php echo $_dob->setDate($this->getFormData()->getDob())->toHtml() ?></li>
|
81 |
+
<?php endif ?>
|
82 |
+
<?php $_taxvat = $this->getLayout()->createBlock('customer/widget_taxvat') ?>
|
83 |
+
<?php if ($_taxvat->isEnabled()): ?>
|
84 |
+
<li><?php echo $_taxvat->setTaxvat($this->getFormData()->getTaxvat())->toHtml() ?></li>
|
85 |
+
<?php endif ?>
|
86 |
+
</ul>
|
87 |
+
</fieldset>
|
88 |
+
<?php if($this->getShowAddressFields()): ?><br/>
|
89 |
+
<input type="hidden" name="create_address" value="1"/>
|
90 |
+
<fieldset class="group-select wide">
|
91 |
+
<div class="head-alt2">
|
92 |
+
<h4 class="title"><?php echo $this->__('Address Information') ?></h4>
|
93 |
+
</div>
|
94 |
+
<ul>
|
95 |
+
<li>
|
96 |
+
<div class="input-box">
|
97 |
+
<label for="company"><?php echo $this->__('Company') ?></label><br/>
|
98 |
+
<input type="text" name="company" id="company" value="<?php echo $this->htmlEscape($this->getFormData()->getCompany()) ?>" title="<?php echo $this->__('Company') ?>" class="input-text"/>
|
99 |
+
</div>
|
100 |
+
<div class="input-box">
|
101 |
+
<label for="lastname"><?php echo $this->__('Telephone') ?> <span class="required">*</span></label><br/>
|
102 |
+
<input type="text" name="telephone" id="telephone" value="<?php echo $this->htmlEscape($this->getFormData()->getTelephone()) ?>" title="<?php echo $this->__('Telephone') ?>" class="required-entry input-text"/>
|
103 |
+
</div>
|
104 |
+
</li>
|
105 |
+
<li>
|
106 |
+
<label for="street_1"><?php echo $this->__('Street Address') ?> <span class="required">*</span></label><br/>
|
107 |
+
<input type="text" name="street[]" value="<?php echo $this->htmlEscape($this->getFormData()->getStreet(1)) ?> " title="<?php echo $this->__('Street Address') ?>" id="street_1" class="required-entry input-text"/>
|
108 |
+
</li>
|
109 |
+
<?php for ($_i=2, $_n=$this->helper('customer/address')->getStreetLines(); $_i<=$_n; $_i++): ?>
|
110 |
+
<li>
|
111 |
+
<input type="text" name="street[]" value="<?php echo $this->htmlEscape($this->getFormData()->getStreet($_i)) ?> " title="<?php echo $this->__('Street Address '.$_i) ?>" id="street_<?php echo $_i?>" class="input-text"/>
|
112 |
+
</li>
|
113 |
+
<?php endfor ?>
|
114 |
+
<li>
|
115 |
+
<div class="input-box">
|
116 |
+
<label for="city"><?php echo $this->__('City') ?> <span class="required">*</span></label><br/>
|
117 |
+
<input type="text" name="city" value="<?php echo $this->htmlEscape($this->getFormData()->getCity()) ?>" title="<?php echo $this->__('City') ?>" class="required-entry input-text" id="city"/>
|
118 |
+
</div>
|
119 |
+
<div class="input-box">
|
120 |
+
<label for="region_id"><?php echo $this->__('State/Province') ?> <span class="required">*</span></label><br/>
|
121 |
+
<select id="region_id" name="region_id" title="<?php echo $this->__('State/Province') ?>" class="validate-select" style="display:none">
|
122 |
+
<option value=""><?php echo $this->__('Please select region, state or province') ?></option>
|
123 |
+
</select>
|
124 |
+
<script type="text/javascript">
|
125 |
+
$('region_id').setAttribute('defaultValue', "<?php echo $this->getFormData()->getRegionId() ?>");
|
126 |
+
</script>
|
127 |
+
<input type="text" id="region" name="region" value="<?php echo $this->htmlEscape($this->getRegion()) ?>" title="<?php echo $this->__('State/Province') ?>" class="input-text" style="display:none"/>
|
128 |
+
</div>
|
129 |
+
</li>
|
130 |
+
<li>
|
131 |
+
<div class="input-box">
|
132 |
+
<label for="zip"><?php echo $this->__('Zip/Postal Code') ?> <span class="required">*</span></label><br/>
|
133 |
+
<input type="text" name="postcode" value="<?php echo $this->htmlEscape($this->getFormData()->getPostcode()) ?>" title="<?php echo $this->__('Zip/Postal Code') ?>" id="zip" class="validate-zip-international required-entry input-text"/>
|
134 |
+
</div>
|
135 |
+
<div class="input-box">
|
136 |
+
<label for="country"><?php echo $this->__('Country') ?> <span class="required">*</span></label><br/>
|
137 |
+
<?php echo $this->getCountryHtmlSelect() ?>
|
138 |
+
</div>
|
139 |
+
</li>
|
140 |
+
</ul>
|
141 |
+
</fieldset>
|
142 |
+
<input type="hidden" name="default_billing" value="1"/>
|
143 |
+
<input type="hidden" name="default_shipping" value="1"/>
|
144 |
+
<?php endif; ?>
|
145 |
+
<fieldset class="group-select wide">
|
146 |
+
<br />
|
147 |
+
<div class="head-alt2">
|
148 |
+
<h4 class="title"><?php echo $this->__('Login Information') ?></h4>
|
149 |
+
</div>
|
150 |
+
<ul>
|
151 |
+
<li>
|
152 |
+
<div class="input-box">
|
153 |
+
<label for="password"><?php echo $this->__('Password') ?> <span class="required">*</span></label><br/>
|
154 |
+
<input type="password" name="password" id="password" title="<?php echo $this->__('Password') ?>" class="required-entry validate-password input-text"/>
|
155 |
+
</div>
|
156 |
+
<div class="input-box">
|
157 |
+
<label for="confirmation"><?php echo $this->__('Confirm Password') ?> <span class="required">*</span></label><br/>
|
158 |
+
<input type="password" name="confirmation" title="<?php echo $this->__('Confirm Password') ?>" id="confirmation" class="required-entry validate-cpassword input-text"/>
|
159 |
+
</div>
|
160 |
+
</li>
|
161 |
+
</ul>
|
162 |
+
</fieldset>
|
163 |
+
<div class="button-set">
|
164 |
+
<p class="required"><?php echo $this->__('* Required Fields') ?></p>
|
165 |
+
<a href="<?php echo $this->getBackUrl() ?>" class="f-left">« <?php echo $this->__('Back') ?></a>
|
166 |
+
<p><input type="submit" value="S'inscrire" class="btnCreateAccount" alt="<?php echo $this->__('Submit') ?>"/></p>
|
167 |
+
</div>
|
168 |
+
</form>
|
169 |
+
<script type="text/javascript">
|
170 |
+
var dataForm = new VarienForm('form-validate', true);
|
171 |
+
<?php if($this->getShowAddressFields()): ?>
|
172 |
+
new RegionUpdater('country', 'region', 'region_id', <?php echo $this->helper('directory')->getRegionJson() ?>);
|
173 |
+
<?php endif ?>
|
174 |
+
</script>
|
app/design/frontend/default/default/template/sponsorship/customer/widget/name.phtml
ADDED
@@ -0,0 +1,176 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Magento
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the Academic Free License (AFL 3.0)
|
8 |
+
* that is bundled with this package in the file LICENSE_AFL.txt.
|
9 |
+
* It is also available through the world-wide-web at this URL:
|
10 |
+
* http://opensource.org/licenses/afl-3.0.php
|
11 |
+
* If you did not receive a copy of the license and are unable to
|
12 |
+
* obtain it through the world-wide-web, please send an email
|
13 |
+
* to license@magentocommerce.com so we can send you a copy immediately.
|
14 |
+
*
|
15 |
+
* DISCLAIMER
|
16 |
+
*
|
17 |
+
* Do not edit or add to this file if you wish to upgrade Magento to newer
|
18 |
+
* versions in the future. If you wish to customize Magento for your
|
19 |
+
* needs please refer to http://www.magentocommerce.com for more information.
|
20 |
+
*
|
21 |
+
* @category design_default
|
22 |
+
* @package Mage
|
23 |
+
* @copyright Copyright (c) 2008 Irubin Consulting Inc. DBA Varien (http://www.varien.com)
|
24 |
+
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
|
25 |
+
*/
|
26 |
+
|
27 |
+
/**
|
28 |
+
USAGE:
|
29 |
+
|
30 |
+
Simple:
|
31 |
+
|
32 |
+
<?php echo $this->getLayout()->createBlock('customer/widget_name')
|
33 |
+
->setObject($this->getAddress())
|
34 |
+
->toHtml() ?>
|
35 |
+
|
36 |
+
For checkout/onepage/shipping.phtml:
|
37 |
+
|
38 |
+
<?php echo $this->getLayout()->createBlock('customer/widget_name')
|
39 |
+
->setObject($this->getAddress())
|
40 |
+
->setFieldIdFormat('shipping:%s')
|
41 |
+
->setFieldNameFormat('shipping[%s]')
|
42 |
+
->setFieldParams('onchange="shipping.setSameAsBilling(false);"')
|
43 |
+
->toHtml() ?>
|
44 |
+
*/
|
45 |
+
?>
|
46 |
+
|
47 |
+
<div class="<?php echo $this->getContainerClassName()?>">
|
48 |
+
<?php if ($this->showPrefix()): ?>
|
49 |
+
<div class="input-box name-prefix">
|
50 |
+
<label for="<?php echo $this->getFieldId('prefix')?>">
|
51 |
+
<?php echo $this->__('Prefix') ?>
|
52 |
+
<?php if ($this->isPrefixRequired()):?><span class="required">*</span><?php endif ?>
|
53 |
+
</label>
|
54 |
+
<br />
|
55 |
+
<?php if ($this->getPrefixOptions()===false): ?>
|
56 |
+
<input type="text"
|
57 |
+
id="<?php echo $this->getFieldId('prefix')?>"
|
58 |
+
name="<?php echo $this->getFieldName('prefix')?>"
|
59 |
+
value="<?php echo $this->htmlEscape($this->getObject()->getPrefix()) ?>"
|
60 |
+
title="<?php echo $this->__('Prefix') ?>"
|
61 |
+
class="<?php if ($this->isPrefixRequired()):?>required-entry<?php endif ?> input-text"
|
62 |
+
<?php echo $this->getFieldParams() ?> />
|
63 |
+
<?php else: ?>
|
64 |
+
<select
|
65 |
+
id="<?php echo $this->getFieldId('prefix')?>"
|
66 |
+
name="<?php echo $this->getFieldName('prefix')?>"
|
67 |
+
title="<?php echo $this->__('Prefix') ?>"
|
68 |
+
<?php if ($this->isPrefixRequired()):?>class="required-entry"<?php endif ?>
|
69 |
+
<?php echo $this->getFieldParams() ?> />
|
70 |
+
<?php foreach ($this->getPrefixOptions() as $_option): ?>
|
71 |
+
<option value="<?php echo $_option?>"
|
72 |
+
<?php if ($this->getObject()->getPrefix()==$_option):?>selected="selected"<?php endif ?>
|
73 |
+
><?php echo $this->__($_option)?></option>
|
74 |
+
<?php endforeach ?>
|
75 |
+
</select>
|
76 |
+
<?php endif ?>
|
77 |
+
</div>
|
78 |
+
<?php endif ?>
|
79 |
+
|
80 |
+
<div class="input-box name-firstname">
|
81 |
+
<label for="<?php echo $this->getFieldId('firstname')?>">
|
82 |
+
<?php echo $this->__('First Name') ?>
|
83 |
+
<span class="required">*</span>
|
84 |
+
</label>
|
85 |
+
<br />
|
86 |
+
<input type="text"
|
87 |
+
id="<?php echo $this->getFieldId('firstname')?>"
|
88 |
+
name="<?php echo $this->getFieldName('firstname')?>"
|
89 |
+
value="<?php
|
90 |
+
if ($this->htmlEscape($this->getObject()->getFirstname())=='')
|
91 |
+
{
|
92 |
+
echo $this->htmlEscape($this->getInvit('firstname'));
|
93 |
+
}
|
94 |
+
else
|
95 |
+
{
|
96 |
+
echo $this->htmlEscape($this->getObject()->getFirstname());
|
97 |
+
}
|
98 |
+
?>"
|
99 |
+
title="<?php echo $this->__('First Name') ?>"
|
100 |
+
class="required-entry input-text"
|
101 |
+
<?php echo $this->getFieldParams() ?> />
|
102 |
+
</div>
|
103 |
+
|
104 |
+
<?php if ($this->showMiddlename()): ?>
|
105 |
+
<div class="input-box name-middlename">
|
106 |
+
<label for="<?php echo $this->getFieldId('middlename')?>">
|
107 |
+
<?php echo $this->__('M.I.') ?>
|
108 |
+
</label>
|
109 |
+
<br />
|
110 |
+
<input type="text"
|
111 |
+
id="<?php echo $this->getFieldId('middlename')?>"
|
112 |
+
name="<?php echo $this->getFieldName('middlename')?>"
|
113 |
+
value="<?php echo $this->htmlEscape($this->getObject()->getMiddlename()) ?>"
|
114 |
+
title="<?php echo $this->__('M.I.') ?>"
|
115 |
+
class="input-text"
|
116 |
+
<?php echo $this->getFieldParams() ?> />
|
117 |
+
</div>
|
118 |
+
<?php endif ?>
|
119 |
+
|
120 |
+
<div class="input-box name-lastname">
|
121 |
+
<label for="<?php echo $this->getFieldId('lastname')?>">
|
122 |
+
<?php echo $this->__('Last Name') ?>
|
123 |
+
<span class="required">*</span>
|
124 |
+
</label>
|
125 |
+
<br />
|
126 |
+
<input type="text"
|
127 |
+
id="<?php echo $this->getFieldId('lastname')?>"
|
128 |
+
name="<?php echo $this->getFieldName('lastname')?>"
|
129 |
+
value="<?php
|
130 |
+
if ($this->htmlEscape($this->getObject()->getLastname())=='')
|
131 |
+
{
|
132 |
+
echo $this->htmlEscape($this->getInvit('lastname'));
|
133 |
+
}
|
134 |
+
else
|
135 |
+
{
|
136 |
+
echo $this->htmlEscape($this->getObject()->getLastname());
|
137 |
+
}
|
138 |
+
?>"
|
139 |
+
title="<?php echo $this->__('Last Name') ?>"
|
140 |
+
class="required-entry input-text"
|
141 |
+
<?php echo $this->getFieldParams() ?> />
|
142 |
+
</div>
|
143 |
+
|
144 |
+
<?php if ($this->showSuffix()): ?>
|
145 |
+
<div class="input-box name-suffix">
|
146 |
+
<label for="<?php echo $this->getFieldId('suffix')?>">
|
147 |
+
<?php echo $this->__('Suffix') ?>
|
148 |
+
<?php if ($this->isSuffixRequired()):?><span class="required">*</span><?php endif ?>
|
149 |
+
</label>
|
150 |
+
<br />
|
151 |
+
<?php if ($this->getSuffixOptions()===false): ?>
|
152 |
+
<input type="text"
|
153 |
+
id="<?php echo $this->getFieldId('suffix')?>"
|
154 |
+
name="<?php echo $this->getFieldName('suffix')?>"
|
155 |
+
value="<?php echo $this->htmlEscape($this->getObject()->getSuffix()) ?>"
|
156 |
+
title="<?php echo $this->__('Suffix') ?>"
|
157 |
+
class="<?php if ($this->isSuffixRequired()):?>required-entry<?php endif ?> input-text"
|
158 |
+
<?php echo $this->getFieldParams() ?> />
|
159 |
+
<?php else: ?>
|
160 |
+
<select
|
161 |
+
id="<?php echo $this->getFieldId('suffix')?>"
|
162 |
+
name="<?php echo $this->getFieldName('suffix')?>"
|
163 |
+
title="<?php echo $this->__('Suffix') ?>"
|
164 |
+
<?php if ($this->isSuffixRequired()):?>class="required-entry"<?php endif ?>
|
165 |
+
<?php echo $this->getFieldParams() ?> />
|
166 |
+
<?php foreach ($this->getSuffixOptions() as $_option): ?>
|
167 |
+
<option value="<?php echo $_option?>"
|
168 |
+
<?php if ($this->getObject()->getSuffix()==$_option):?>selected="selected"<?php endif ?>
|
169 |
+
><?php echo $this->__($_option)?></option>
|
170 |
+
<?php endforeach ?>
|
171 |
+
</select>
|
172 |
+
<?php endif ?>
|
173 |
+
</div>
|
174 |
+
<?php endif ?>
|
175 |
+
|
176 |
+
</div>
|
app/design/frontend/default/default/template/sponsorship/customer/widget/virement.phtml
ADDED
@@ -0,0 +1,32 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<!--
|
2 |
+
/**
|
3 |
+
* @category Auguria
|
4 |
+
* @package Auguria_Sponsorship
|
5 |
+
* @author Auguria
|
6 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
7 |
+
*/
|
8 |
+
-->
|
9 |
+
<div class="input-box" >
|
10 |
+
<label for="<?php echo $this->getFieldId('iban')?>">
|
11 |
+
<?php echo $this->__('IBAN') ?>
|
12 |
+
</label>
|
13 |
+
<br />
|
14 |
+
<input type="text"
|
15 |
+
id="<?php echo $this->getFieldId('iban')?>"
|
16 |
+
name="<?php echo $this->getFieldName('iban')?>"
|
17 |
+
value="<?php echo $this->htmlEscape($this->getIban()) ?>"
|
18 |
+
class="input-text"
|
19 |
+
<?php echo $this->getFieldParams() ?> />
|
20 |
+
</div>
|
21 |
+
<div class="input-box" >
|
22 |
+
<label for="<?php echo $this->getFieldId('siret')?>">
|
23 |
+
<?php echo $this->__('Campany number') ?>
|
24 |
+
</label>
|
25 |
+
<br />
|
26 |
+
<input type="text"
|
27 |
+
id="<?php echo $this->getFieldId('siret')?>"
|
28 |
+
name="<?php echo $this->getFieldName('siret')?>"
|
29 |
+
value="<?php echo $this->htmlEscape($this->getSiret()) ?>"
|
30 |
+
class="input-text"
|
31 |
+
<?php echo $this->getFieldParams() ?> />
|
32 |
+
</div>
|
app/design/frontend/default/default/template/sponsorship/sponsorship.phtml
ADDED
@@ -0,0 +1,149 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<!--
|
2 |
+
/**
|
3 |
+
* @category Auguria
|
4 |
+
* @package Auguria_Sponsorship
|
5 |
+
* @author Auguria
|
6 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
7 |
+
*/
|
8 |
+
-->
|
9 |
+
<script type="text/javascript">
|
10 |
+
//<![CDATA[
|
11 |
+
var i=1;
|
12 |
+
var recipCount = 1;
|
13 |
+
var maxRecip = <?php echo $this->getMaxRecipients() ?>;
|
14 |
+
function remove_recipient(i){
|
15 |
+
$('recipient_firstname'+i).up(2).remove();
|
16 |
+
recipCount = recipCount-1;
|
17 |
+
if(recipCount<maxRecip && maxRecip != 0) {
|
18 |
+
$('add_recipient_button').show();
|
19 |
+
$('max_recipient_message').hide();
|
20 |
+
}
|
21 |
+
return false;
|
22 |
+
}
|
23 |
+
|
24 |
+
function add_recipient(){
|
25 |
+
ul = $('recipient_options');
|
26 |
+
var li_mail = Element.extend(document.createElement("LI"));
|
27 |
+
li_mail.addClassName('addElement');
|
28 |
+
|
29 |
+
li_mail.innerHTML = '<div class="left"><label for="recipient_firstname" class="required"><em>*<\/em><?php echo $this->__('First name:') ?><\/label><br /><div style="width:250px"><input name="recipient[firstname][]" type="text" class="input-text required-entry" id="recipient_firstname'+i+'" style="width:250px;" /><\/div><\/div>';
|
30 |
+
li_mail.innerHTML += '<div class="right"><label for="recipient_lastname" class="required"><em>*<\/em><?php echo $this->__('Last name:') ?><\/label><br /><div style="width:250px"><input name="recipient[lastname][]" type="text" class="input-text required-entry" id="recipient_lastname'+i+'" style="width:250px;" /><\/div><\/div>';
|
31 |
+
li_mail.innerHTML += '<div class="left"><label for="recipient_email" class="required"><em>*<\/em><?php echo $this->__('Email Address:') ?><\/label><br /><div style="width:250px"><input name="recipient[email][]" value="" title="<?php echo $this->__('Email Address') ?>" id="recipient_email'+i+'" type="text" class="input-text required-entry validate-email" style="width:250px;" /><\/div><\/div>';
|
32 |
+
|
33 |
+
li_mail.innerHTML += '<button style="margin-top:10px" class="button right" onclick="remove_recipient('+i+');" type="button"><span><?php echo $this->__('Remove Recipient') ?><\/span><\/button>';
|
34 |
+
i++;
|
35 |
+
recipCount++;
|
36 |
+
if(recipCount>=maxRecip && maxRecip != 0) {
|
37 |
+
$('add_recipient_button').hide();
|
38 |
+
$('max_recipient_message').show();
|
39 |
+
}
|
40 |
+
|
41 |
+
ul.appendChild(li_mail);
|
42 |
+
}
|
43 |
+
//]]>
|
44 |
+
</script>
|
45 |
+
<div id="messages_product_view"><?php echo $this->getMessagesBlock()->getGroupedHtml() ?></div>
|
46 |
+
<div class="page-title">
|
47 |
+
<h1><?php echo $this->__('Sponsor friends') ?></h1>
|
48 |
+
</div>
|
49 |
+
<form action="<?php echo $this->getUrl('sponsorship/index/post') ?>" id="sponsorship" method="post">
|
50 |
+
<div class="fieldset sender_options">
|
51 |
+
<h2 class="legend"><?php echo $this->__('Sender:') ?></h2>
|
52 |
+
<ul class="form-list" id="sender_options">
|
53 |
+
<li>
|
54 |
+
<div class="left">
|
55 |
+
<label for="sender_name" class="required"><em>*</em><?php echo $this->__('Name:') ?></label><br/>
|
56 |
+
<div style="width:250px"><input name="sender[name]" value="<?php echo $this->__($this->getUserName()) ?>" title="<?php echo $this->__('Name') ?>" id="sender_name" type="text" class="input-text required-entry" style="width:250px;" /></div>
|
57 |
+
<input name="sender[id]" value="<?php echo $this->getCustomerId(); ?>" id="sender_id" type="hidden"/>
|
58 |
+
</div>
|
59 |
+
<div class="right">
|
60 |
+
<label for="sender_email" class="required"><em>*</em><?php echo $this->__('Email:') ?> </label><br/>
|
61 |
+
<div style="width:250px"><input name="sender[email]" value="<?php echo $this->__($this->getUserEmail()) ?>" title="<?php echo $this->__('Email Address') ?>" id="sender_email" type="text" class="input-text required-entry validate-email" style="width:250px;" /></div>
|
62 |
+
</div>
|
63 |
+
</li>
|
64 |
+
</ul>
|
65 |
+
</div>
|
66 |
+
<div class="fieldset message_options">
|
67 |
+
<h2 class="legend"><?php echo $this->__('Message:') ?></h2>
|
68 |
+
<ul class="form-list" id="message_options">
|
69 |
+
<li>
|
70 |
+
<div class="left">
|
71 |
+
<label for="message_subject" class="required"><em>*</em><?php echo $this->__('Subject:') ?></label><br/>
|
72 |
+
<div style="width:250px">
|
73 |
+
<input name="message[subject]" value="<?php echo Mage::helper('sponsorship/mail')->getSubject() ?>" title="<?php echo $this->__('Subject') ?>" id="message_subject" type="text" class="input-text required-entry" style="width:250px;" />
|
74 |
+
</div>
|
75 |
+
</div>
|
76 |
+
</li>
|
77 |
+
<li>
|
78 |
+
<div class="left">
|
79 |
+
<label for="message_header" class="required"><em>*</em><?php echo $this->__('Your message will be preceded by:') ?></label>
|
80 |
+
<div>
|
81 |
+
<?php
|
82 |
+
echo Mage::helper('sponsorship/mail')->getHeaderMessage($this->__('First name'),$this->__('Last name'));
|
83 |
+
?>
|
84 |
+
<input name="message[header]" value="1" title="<?php echo $this->__('Subject') ?>" id="message_header" type="hidden" />
|
85 |
+
</div>
|
86 |
+
</div>
|
87 |
+
</li>
|
88 |
+
<li>
|
89 |
+
<div>
|
90 |
+
<label for="message_body" class="required"><em>*</em><?php echo $this->__('Your message:') ?></label>
|
91 |
+
<textarea name="message[body]" class="input-text required-entry" id="message_body" title="<?php echo $this->__('Your message') ?>" cols="3" rows="8" style="width:100%;height:180px"><?php
|
92 |
+
echo Mage::helper('sponsorship/mail')->getMessage();
|
93 |
+
?></textarea>
|
94 |
+
</div>
|
95 |
+
</li>
|
96 |
+
<li>
|
97 |
+
<div>
|
98 |
+
<label for="message_footer" class="required"><em>*</em><?php echo $this->__('And it ends as follows:') ?></label>
|
99 |
+
<br/>
|
100 |
+
<div>
|
101 |
+
<?php
|
102 |
+
echo $this->getFooterMessage();
|
103 |
+
?>
|
104 |
+
</div>
|
105 |
+
</div>
|
106 |
+
</li>
|
107 |
+
</ul>
|
108 |
+
</div>
|
109 |
+
<div class="fieldset recipient_options">
|
110 |
+
<h2 class="legend"><?php echo $this->__('Recipients:') ?></h2>
|
111 |
+
<ul class="form-list" id="recipient_options">
|
112 |
+
<li>
|
113 |
+
<div class="left">
|
114 |
+
<label for="recipient_firstname" class="required"><em>*</em><?php echo $this->__('First name:') ?></label><br/>
|
115 |
+
<div style="width:250px"><input name="recipient[firstname][]" type="text" class="input-text required-entry" id="recipient_firstname" style="width:250px;" /></div>
|
116 |
+
</div>
|
117 |
+
<div class="right">
|
118 |
+
<label for="recipient_lastname" class="required"><em>*</em><?php echo $this->__('Last name:') ?></label><br/>
|
119 |
+
<div style="width:250px"><input name="recipient[lastname][]" type="text" class="input-text required-entry" id="recipient_lastname" style="width:250px;" /></div>
|
120 |
+
</div>
|
121 |
+
<div class="left">
|
122 |
+
<label for="recipient_email" class="required"><em>*</em><?php echo $this->__('Email Address:') ?></label><br/>
|
123 |
+
<div style="width:250px"><input name="recipient[email][]" value="" title="<?php echo $this->__('Email Address') ?>" id="recipient_email" type="text" class="input-text required-entry validate-email" style="width:250px;" /></div>
|
124 |
+
</div>
|
125 |
+
</li>
|
126 |
+
</ul>
|
127 |
+
<div id="max_recipient_message" style="display:none">
|
128 |
+
<?php if ($this->getMaxRecipients()): ?>
|
129 |
+
<?php echo $this->__('Maximum %d email addresses allowed.', $this->getMaxRecipients()) ?>
|
130 |
+
<?php endif; ?>
|
131 |
+
</div>
|
132 |
+
<?php
|
133 |
+
if (1 < $this->getMaxRecipients()): ?>
|
134 |
+
<div id="add_recipient_button" class="buttons-set">
|
135 |
+
<button class="button" onclick="add_recipient();" type="button"><span><?php echo $this->__('Add Recipient') ?></span></button>
|
136 |
+
</div>
|
137 |
+
<?php endif; ?>
|
138 |
+
<div style="clear:both"></div>
|
139 |
+
</div>
|
140 |
+
<div class="buttons-set">
|
141 |
+
<p class="required"><?php echo $this->__('* Required Fields') ?></p>
|
142 |
+
<p class="back-link"><a href="<?php echo $this->getBackUrl() ?>"><small>« </small><?php echo $this->__('Back') ?></a></p>
|
143 |
+
<button class="button" type="submit"><span><?php echo $this->__('Send email') ?></span></button>
|
144 |
+
</div>
|
145 |
+
</form>
|
146 |
+
|
147 |
+
<script type="text/javascript">
|
148 |
+
var sponsorship = new VarienForm('sponsorship', true);
|
149 |
+
</script>
|
app/etc/modules/Auguria_Sponsorship.xml
ADDED
@@ -0,0 +1,17 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<!--
|
3 |
+
/**
|
4 |
+
* @category Auguria
|
5 |
+
* @package Auguria_Sponsorship
|
6 |
+
* @author ModuleCreator
|
7 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
8 |
+
*/
|
9 |
+
-->
|
10 |
+
<config>
|
11 |
+
<modules>
|
12 |
+
<Auguria_Sponsorship>
|
13 |
+
<active>true</active>
|
14 |
+
<codePool>community</codePool>
|
15 |
+
</Auguria_Sponsorship>
|
16 |
+
</modules>
|
17 |
+
</config>
|
app/locale/en_US/template/email/sponsorship_coupon.html
ADDED
@@ -0,0 +1,76 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{* This is a comment block
|
2 |
+
|
3 |
+
@category Auguria
|
4 |
+
@package Auguria_Sponsorship
|
5 |
+
@author Auguria
|
6 |
+
@license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
7 |
+
|
8 |
+
Available vars in sponsorship template:
|
9 |
+
subject
|
10 |
+
sender_id
|
11 |
+
sender_name
|
12 |
+
sender_email
|
13 |
+
sender_name
|
14 |
+
sender_email
|
15 |
+
recipient_firstname
|
16 |
+
recipient_lastname
|
17 |
+
discount_amount
|
18 |
+
coupon_code
|
19 |
+
|
20 |
+
*}<!--@subject {{var data.subject}} @-->
|
21 |
+
|
22 |
+
Dear {{var data.recipient_firstname}} {{var data.recipient_lastname}},
|
23 |
+
|
24 |
+
Your vouchers points exchange has been successfully registred.
|
25 |
+
|
26 |
+
You can now receive your discount voucher worth {{var data.discount_amount}} euros, indicating the following code discounts:
|
27 |
+
|
28 |
+
{{var data.coupon_code}}
|
29 |
+
|
30 |
+
{{store url=""}}
|
31 |
+
|
32 |
+
--BOUNDARY_TEXT_OF_CHOICE_FOR_AUGURIA_SPONSORSHIP
|
33 |
+
|
34 |
+
<style type="text/css">
|
35 |
+
body,td { color:#2f2f2f; font:11px/1.35em Verdana, Arial, Helvetica, sans-serif; }
|
36 |
+
</style>
|
37 |
+
|
38 |
+
<div style="font:11px/1.35em Verdana, Arial, Helvetica, sans-serif;">
|
39 |
+
<table cellspacing="0" cellpadding="0" border="0" width="98%" style="margin-top:10px; font:11px/1.35em Verdana, Arial, Helvetica, sans-serif; margin-bottom:10px;">
|
40 |
+
<tr>
|
41 |
+
<td align="center" valign="top">
|
42 |
+
<!-- [ header starts here] -->
|
43 |
+
<table cellspacing="0" cellpadding="0" border="0" width="650">
|
44 |
+
<tr>
|
45 |
+
<td valign="top">
|
46 |
+
<a href="{{store url=""}}">
|
47 |
+
<img src="{{skin url="images/logo_email.gif" _area='frontend'}}" alt="{{var data.store_name}}" style="margin-bottom:10px;" border="0"/>
|
48 |
+
</a>
|
49 |
+
</td>
|
50 |
+
</tr>
|
51 |
+
</table>
|
52 |
+
|
53 |
+
</td>
|
54 |
+
</tr>
|
55 |
+
<tr>
|
56 |
+
<td align="center" valign="top">
|
57 |
+
<!-- [ middle starts here] -->
|
58 |
+
<table cellspacing="0" cellpadding="0" border="0" width="650">
|
59 |
+
<tr>
|
60 |
+
<td valign="top">
|
61 |
+
<p><strong>Dear {{var data.recipient_firstname}} {{var data.recipient_lastname}}</strong>,</p>
|
62 |
+
<p>Your vouchers points exchange has been successfully registred.</p>
|
63 |
+
<p>You can now receive your discount voucher worth <strong>{{var data.discount_amount}} euros</strong>, indicating the following code discounts:</p>
|
64 |
+
<h1 align="center">{{var data.coupon_code}}</h1>
|
65 |
+
</td>
|
66 |
+
</tr>
|
67 |
+
<tr>
|
68 |
+
<td valign="top">
|
69 |
+
<a href="{{store url=""}}">{{var data.store_name}}</a>
|
70 |
+
</td>
|
71 |
+
</tr>
|
72 |
+
</table>
|
73 |
+
</td>
|
74 |
+
</tr>
|
75 |
+
</table>
|
76 |
+
</div>
|
app/locale/en_US/template/email/sponsorship_invitation.html
ADDED
@@ -0,0 +1,60 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{* This is a comment block
|
2 |
+
|
3 |
+
@category Auguria
|
4 |
+
@package Auguria_Sponsorship
|
5 |
+
@author Auguria
|
6 |
+
@license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
7 |
+
|
8 |
+
Available vars in sponsorship template:
|
9 |
+
data.sender_name
|
10 |
+
data.sender_email
|
11 |
+
data.subject
|
12 |
+
data.html_message
|
13 |
+
data.text_message
|
14 |
+
data.html_footer
|
15 |
+
data.text_footer
|
16 |
+
data.recipient_email
|
17 |
+
data.sponsorship_url
|
18 |
+
|
19 |
+
*}<!--@subject {{var data.subject}} @-->
|
20 |
+
{{var data.text_message}}
|
21 |
+
{{var data.text_footer}}
|
22 |
+
|
23 |
+
--BOUNDARY_TEXT_OF_CHOICE_FOR_AUGURIA_SPONSORSHIP
|
24 |
+
|
25 |
+
<style type="text/css">
|
26 |
+
body,td { color:#2f2f2f; font:11px/1.35em Verdana, Arial, Helvetica, sans-serif; }
|
27 |
+
</style>
|
28 |
+
|
29 |
+
<div style="font:11px/1.35em Verdana, Arial, Helvetica, sans-serif;">
|
30 |
+
<table cellspacing="0" cellpadding="0" border="0" width="98%" style="margin-top:10px; font:11px/1.35em Verdana, Arial, Helvetica, sans-serif; margin-bottom:10px;">
|
31 |
+
<tr>
|
32 |
+
<td align="center" valign="top">
|
33 |
+
<!-- [ header starts here] -->
|
34 |
+
<table cellspacing="0" cellpadding="0" border="0" width="650">
|
35 |
+
<tr>
|
36 |
+
<td valign="top">
|
37 |
+
<a href="{{var data.sponsorship_url}}">
|
38 |
+
<img src="{{skin url="images/logo_email.gif" _area='frontend'}}" alt="{{var order.getStoreGroupName()}}" style="margin-bottom:10px;" border="0"/>
|
39 |
+
</a>
|
40 |
+
</td>
|
41 |
+
</tr>
|
42 |
+
</table>
|
43 |
+
|
44 |
+
</td>
|
45 |
+
</tr>
|
46 |
+
<tr>
|
47 |
+
<td align="center" valign="top">
|
48 |
+
<!-- [ middle starts here] -->
|
49 |
+
<table cellspacing="0" cellpadding="0" border="0" width="650">
|
50 |
+
<tr>
|
51 |
+
<td valign="top">
|
52 |
+
<pre>{{var data.html_message}}</pre>
|
53 |
+
<pre>{{var data.html_footer}}</pre>
|
54 |
+
</td>
|
55 |
+
</tr>
|
56 |
+
</table>
|
57 |
+
</td>
|
58 |
+
</tr>
|
59 |
+
</table>
|
60 |
+
</div>
|
app/locale/fr_FR/Auguria_Sponsorship.csv
ADDED
@@ -0,0 +1,184 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
"Action","Action"
|
2 |
+
"'%s' is not a valid number.","'%s' n'est pas un nombre valide."
|
3 |
+
"'%s' is not an integer.","'%s' n'est pas un entier."
|
4 |
+
"'%s' is not greater than 0.","'%s' n'est pas supérieur à 0."
|
5 |
+
"%s is already an email to our customers","%s est déjà l'email d'un de nos clients"
|
6 |
+
"%s points exchange for customer (%s)","Échange de points %s pour le client (%s)"
|
7 |
+
"%s vouchers points exchange","%s échange de points en bon de réduction"
|
8 |
+
"<a href='%s'>%s</a>","<a href='%s'>%s</a>"
|
9 |
+
"A value is required.","Une valeur est requise."
|
10 |
+
"Active godsons:","Filleuls actifs :"
|
11 |
+
"Add a change","Ajouter un échange"
|
12 |
+
"Add a sponsorship","Ajouter un parrainage"
|
13 |
+
"Add an invitation","Ajouter une invitation"
|
14 |
+
"Allow to send invitations to customers who have never ordered","Autoriser l'envoie d'invitations aux clients n'ayant jamais commandé"
|
15 |
+
"An error occurred while saving your request.","Une erreur est survenue lors de l'enregistrement de votre demande."
|
16 |
+
"An error occurred while sending mail.","Une erreur est survenue lors de l'envoi du mail."
|
17 |
+
"An error occurred, the mail to %s could not be delivred.","Une erreur est survenue, le mail destiné à %s n'a pas pu être délivré."
|
18 |
+
"And it ends as follows:","Et il se terminera comme suit :"
|
19 |
+
"Are you sure to process mass action?","Êtes vous sure de vouloir procéder à une action de masse ?"
|
20 |
+
"But it could not be saved.","Mais il n'a pas pu être enregistré."
|
21 |
+
"Calculation period of the maximum allowed for an individual (days)","Période de calcul du maximum autorisé pour un particulier (jours)"
|
22 |
+
"Campany number","SIRET"
|
23 |
+
"Canceled","Annulé"
|
24 |
+
"Cash","Cash"
|
25 |
+
"cash","cash"
|
26 |
+
"Cash exchange enabled","Échange en cash activé"
|
27 |
+
"Change information","Information sur l'échange"
|
28 |
+
"Change your points into:","Changez vos points en :"
|
29 |
+
"Conversion rate of points in currency","Taux de conversion des points en monnaie"
|
30 |
+
"coupon","bon de réduction"
|
31 |
+
"Creation date","Date de création"
|
32 |
+
"Customer","Client"
|
33 |
+
"Customer ID","ID Client"
|
34 |
+
"Customer name","Nom client"
|
35 |
+
"Date","Date"
|
36 |
+
"Date first invitation","Date de la première invitation"
|
37 |
+
"Date last mail","Date du dernier email"
|
38 |
+
"Dear %s %s,","Bonjour %s %s,"
|
39 |
+
"Details","Détails"
|
40 |
+
"Edit","Éditer"
|
41 |
+
"Edition of the change '%s'","Édition de l'échange '%s'"
|
42 |
+
"Edition of the invitation '%s'","Édition de l'invitation '%s'"
|
43 |
+
"Edition of the sponsorship '%s'","Édition du parrainage '%s'"
|
44 |
+
"emptyResults","Aucun résultat"
|
45 |
+
"Enter the cash you want.","Indiquez le cash que vous souhaitez obtenir."
|
46 |
+
"Enter the points you want to convert.","Indiquez les points que vous voulez convertir."
|
47 |
+
"errorData","Erreur de données"
|
48 |
+
"errorURL","Erreur URL"
|
49 |
+
"Exchange detail","Détail échange"
|
50 |
+
"Exchange of your %s points into %s","Échange de vos points %s en %s"
|
51 |
+
"Exported","Exporté"
|
52 |
+
"Fidelity","Fidélité"
|
53 |
+
"fidelity","fidélité"
|
54 |
+
"Fidelity and Sponsorship","Fidélité et Parrainage"
|
55 |
+
"Fidelity balance:","Solde fidélité :"
|
56 |
+
"Fidelity module activated","Module de fidélité activé"
|
57 |
+
"Fidelity options","Options de fidélité"
|
58 |
+
"Fidelity points","Points fidélité"
|
59 |
+
"Fidelity points by fixed amount","Points de fidélité en montant fixe"
|
60 |
+
"Fidelity points by fixed amount for whole cart","Points de fidélités fixe sur tout le panier"
|
61 |
+
"Fidelity points by percentage of the original price","Points de fidélité en pourcentage du prix"
|
62 |
+
"Fidelity points:","Points fidélité :"
|
63 |
+
"filterLabel","Filtrer la colonne :"
|
64 |
+
"First name","Prénom"
|
65 |
+
"First name:","Prénom :"
|
66 |
+
"gift","cadeau"
|
67 |
+
"Gift exchange enabled","Échange en cadeaux activé"
|
68 |
+
"Gifts","Cadeaux"
|
69 |
+
"Godson","Filleul"
|
70 |
+
"Godson ID","ID Filleul"
|
71 |
+
"Godson name","Nom filleul"
|
72 |
+
"Guest first name","Prénom invité"
|
73 |
+
"Guest last name","Nom invité"
|
74 |
+
"Guest mail","Email invité"
|
75 |
+
"Guest name","Nom invité"
|
76 |
+
"IBAN","IBAN"
|
77 |
+
"ID","ID"
|
78 |
+
"Inactivity time before removal of the sponsorship link (days)","Temps d'inactivité avant suppression du lien de parrainage (jours)"
|
79 |
+
"Invalid IBAN code ""%s""","Le code IBAN ""%s"" est invalide"
|
80 |
+
"Invitation detail","Détail de l'invitation"
|
81 |
+
"Invitation does not exist","L'invitation n'existe pas"
|
82 |
+
"Invitation information","Information sur l'invitation"
|
83 |
+
"Invitation to %s","Invitation %s"
|
84 |
+
"Invitation was successfully saved","L'invitation a bien été enregistrée"
|
85 |
+
"Invitations list","Liste des invitations"
|
86 |
+
"Last name","Nom"
|
87 |
+
"Last name:","Nom :"
|
88 |
+
"Last order date","Date dernière commande"
|
89 |
+
"Listing date","Date inscription"
|
90 |
+
"loading","chargement"
|
91 |
+
"Max invitations","Nombre max d'invitations"
|
92 |
+
"Maximum amount permitted without company number","Montant maximum autorisé sans SIRET"
|
93 |
+
"Maximum levels of sponsorship","Nombre maximum de niveaux de parrainage"
|
94 |
+
"Message","Message"
|
95 |
+
"Module","Module"
|
96 |
+
"Number of sponsorships","Nombre de parrainages"
|
97 |
+
"Once you will have points, you can change them into:","Lorsque vous aurez des points, vous pourrez les changer en :"
|
98 |
+
"paginationFirst","Première"
|
99 |
+
"paginationLast","Dernière"
|
100 |
+
"paginationNext","Suivante"
|
101 |
+
"paginationOf"," de "
|
102 |
+
"paginationPages","page(s)"
|
103 |
+
"paginationPrev","Précédente"
|
104 |
+
"Please check the form fields.","Veuillez vérifier les champs du formulaire."
|
105 |
+
"Please select changes","Merci de sélectionner des échanges"
|
106 |
+
"Points","Points"
|
107 |
+
"Points exchanges list","Liste des échanges de points"
|
108 |
+
"Points to exchange:","Points à échanger :"
|
109 |
+
"Principles of Sponsorship","Principes du parrainage"
|
110 |
+
"Ratio applied from level 2 to calculate the points of the sponsor (in percentage)","Ratio appliqué à partir du niveau 2, pour le calcul des points du parrain (en pourcentage)"
|
111 |
+
"Recall","Relancer"
|
112 |
+
"Recall %s %s","Relance de %s %s"
|
113 |
+
"Recipients:","Destinataires :"
|
114 |
+
"Recovery date","Date de relance"
|
115 |
+
"Related ID","ID parent"
|
116 |
+
"Related mail","Email parent"
|
117 |
+
"Related name","Nom parent"
|
118 |
+
"searchLabel","Recherche"
|
119 |
+
"Solved","Réglé"
|
120 |
+
"Special Rate","Taux spécial"
|
121 |
+
"Sponsor","Parrain"
|
122 |
+
"sponsor","parrainage"
|
123 |
+
"Sponsor friends","Parrainez des amis"
|
124 |
+
"Sponsor ID","ID parrain"
|
125 |
+
"Sponsorship","Parrainage"
|
126 |
+
"Sponsorship balance:","Solde parrainage :"
|
127 |
+
"Sponsorship coupon","Bon de réduction parrainage"
|
128 |
+
"Sponsorship date","Date de parrainage"
|
129 |
+
"Sponsorship detail","Détail parrainage"
|
130 |
+
"Sponsorship information","Information sur le parrainage"
|
131 |
+
"Sponsorship invitation","Invitation parrainage"
|
132 |
+
"Sponsorship mail options","Options des mails de parrainage"
|
133 |
+
"Sponsorship module activated","Module de parrainage activé"
|
134 |
+
"Sponsorship options","Options de parrainage"
|
135 |
+
"Sponsorship points","Points parrainage"
|
136 |
+
"Sponsorship points by fixed amount","Points de parrainage en montant fixe"
|
137 |
+
"Sponsorship points by fixed amount for whole cart","Points de parrainage fixe sur tout le panier"
|
138 |
+
"Sponsorship points by percentage of the original price","Points de parrainage en pourcentage du prix"
|
139 |
+
"Sponsorship points:","Points parrainage :"
|
140 |
+
"Sponsorship was successfully saved","Le parrainage a bien été mis à jour"
|
141 |
+
"Sponsorships list","Liste des parrainages"
|
142 |
+
"Status","Statut"
|
143 |
+
"Subject:","Sujet :"
|
144 |
+
"The change has been successfully recorded","L'échange a bien été enregistré"
|
145 |
+
"The exchange of %s points in %s is disabled.","Le change des points %s en %s est désactivé."
|
146 |
+
"The gifts exchange is not yet implemented.","L'échange en cadeaux n'est pas encore disponible."
|
147 |
+
"This change doesn't exist","L'échange n'existe pas"
|
148 |
+
"This sponsorship doesn't exist","Ce parrainage n'existe pas"
|
149 |
+
"Time to send it automatically (days)","Temps avant la relance automatique (jours)"
|
150 |
+
"Time validity invitations (days)","Temps de validité des invitations (jours)"
|
151 |
+
"To change more cash, you must specify a company number.","Pour changer plus de cash, vous devez indiquer un numéro SIRET."
|
152 |
+
"To change your points into cash, you must indicate your IBAN.","Pour changer vos points en cash, vous devez indiquer votre code IBAN."
|
153 |
+
"Type","Type"
|
154 |
+
"Unable to find change to save","Impossible de trouver l'échange à enregistrer"
|
155 |
+
"Unable to find invitation to save","Impossible de trouver l'invitation à enregistrer"
|
156 |
+
"Unable to find sponsorship to save","Impossible de trouver le parrainage à enregistrer"
|
157 |
+
"Update status","Modifier le statut"
|
158 |
+
"Use of your fidelity points","Utilisation de vos points fidélité"
|
159 |
+
"Use of your sponsorship points","Utilisation de vos points parrainage"
|
160 |
+
"Validate","Valider"
|
161 |
+
"Value","Valeur"
|
162 |
+
"Voucher exchange enabled","Échange en bons de réductions activé"
|
163 |
+
"Voucher exchange mail options","Options des mails d'échange de points en bon de réduction"
|
164 |
+
"Vouchers","Bons de réduction"
|
165 |
+
"Vouchers:","Bons de réduction :"
|
166 |
+
"Waiting","En attente"
|
167 |
+
"Winning","Points gagnés"
|
168 |
+
"You do not have active godson.","Vous n'avez pas de filleul actif."
|
169 |
+
"You do not have as many points.","Vous ne disposez pas d'autant de points."
|
170 |
+
"You have %d points.","Vous disposez de %d points."
|
171 |
+
"You must already have purchased to sponsor.","Vous devez déjà avoir commandé pour parrainer."
|
172 |
+
"You should visit this website. It offers interesting products.","Tu devrais aller sur ce site. Ils ont des produits intéressants."
|
173 |
+
"Your email has been successfully sent.","Votre email a bien été envoyé."
|
174 |
+
"Your godsons","Vos filleuls"
|
175 |
+
"Your invitations","Vos invitations"
|
176 |
+
"Your lastest orders","Vos dernières commandes"
|
177 |
+
"Your mail has not been sent, please try again later.","Votre mail n'a pas pu être délivré, veuillez essayer plus tard."
|
178 |
+
"Your message","Votre message"
|
179 |
+
"Your message will be preceded by:","Votre message sera précédé de :"
|
180 |
+
"Your message will ends as follows:","Votre message se terminera comme suit :"
|
181 |
+
"Your message:","Votre message :"
|
182 |
+
"Your points exchanges:","Vos échanges de points :"
|
183 |
+
"Your request has been submitted, you will soon receive an email confirmation.","Votre demande a bien été transmise, vous recevrez bientôt un mail de confirmation."
|
184 |
+
"You do not have yet send invit.","Vous n'avez pas encore envoyé d'invitation."
|
app/locale/fr_FR/template/email/sponsorship_coupon.html
ADDED
@@ -0,0 +1,76 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{* This is a comment block
|
2 |
+
|
3 |
+
@category Auguria
|
4 |
+
@package Auguria_Sponsorship
|
5 |
+
@author Auguria
|
6 |
+
@license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
7 |
+
|
8 |
+
Available vars in sponsorship template:
|
9 |
+
subject
|
10 |
+
sender_id
|
11 |
+
sender_name
|
12 |
+
sender_email
|
13 |
+
sender_name
|
14 |
+
sender_email
|
15 |
+
recipient_firstname
|
16 |
+
recipient_lastname
|
17 |
+
discount_amount
|
18 |
+
coupon_code
|
19 |
+
|
20 |
+
*}<!--@subject {{var data.subject}} @-->
|
21 |
+
|
22 |
+
Bonjour {{var data.recipient_firstname}} {{var data.recipient_lastname}},
|
23 |
+
|
24 |
+
Votre échange de points en bon de réduction a bien été enregistré.
|
25 |
+
|
26 |
+
Vous pouvez dès maintenant bénéficier de votre bon de réduction d'une valeur de {{var data.discount_amount}} euros, en indiquant le code de remises suivant :
|
27 |
+
|
28 |
+
{{var data.coupon_code}}
|
29 |
+
|
30 |
+
{{store url=""}}
|
31 |
+
|
32 |
+
--BOUNDARY_TEXT_OF_CHOICE_FOR_AUGURIA_SPONSORSHIP
|
33 |
+
|
34 |
+
<style type="text/css">
|
35 |
+
body,td { color:#2f2f2f; font:11px/1.35em Verdana, Arial, Helvetica, sans-serif; }
|
36 |
+
</style>
|
37 |
+
|
38 |
+
<div style="font:11px/1.35em Verdana, Arial, Helvetica, sans-serif;">
|
39 |
+
<table cellspacing="0" cellpadding="0" border="0" width="98%" style="margin-top:10px; font:11px/1.35em Verdana, Arial, Helvetica, sans-serif; margin-bottom:10px;">
|
40 |
+
<tr>
|
41 |
+
<td align="center" valign="top">
|
42 |
+
<!-- [ header starts here] -->
|
43 |
+
<table cellspacing="0" cellpadding="0" border="0" width="650">
|
44 |
+
<tr>
|
45 |
+
<td valign="top">
|
46 |
+
<a href="{{store url=""}}">
|
47 |
+
<img src="{{skin url="images/logo_email.gif" _area='frontend'}}" alt="{{var data.store_name}}" style="margin-bottom:10px;" border="0"/>
|
48 |
+
</a>
|
49 |
+
</td>
|
50 |
+
</tr>
|
51 |
+
</table>
|
52 |
+
|
53 |
+
</td>
|
54 |
+
</tr>
|
55 |
+
<tr>
|
56 |
+
<td align="center" valign="top">
|
57 |
+
<!-- [ middle starts here] -->
|
58 |
+
<table cellspacing="0" cellpadding="0" border="0" width="650">
|
59 |
+
<tr>
|
60 |
+
<td valign="top">
|
61 |
+
<p><strong>Bonjour {{var data.recipient_firstname}} {{var data.recipient_lastname}}</strong>,</p>
|
62 |
+
<p>Votre échange de points en bon de réduction a bien été enregistré.</p>
|
63 |
+
<p>Vous pouvez dès maintenant bénéficier de votre bon de réduction d'une valeur de <strong>{{var data.discount_amount}} euros</strong>, en indiquant le code de remises suivant :</p>
|
64 |
+
<h1 align="center">{{var data.coupon_code}}</h1>
|
65 |
+
</td>
|
66 |
+
</tr>
|
67 |
+
<tr>
|
68 |
+
<td valign="top">
|
69 |
+
<a href="{{store url=""}}">{{var data.store_name}}</a>
|
70 |
+
</td>
|
71 |
+
</tr>
|
72 |
+
</table>
|
73 |
+
</td>
|
74 |
+
</tr>
|
75 |
+
</table>
|
76 |
+
</div>
|
app/locale/fr_FR/template/email/sponsorship_invitation.html
ADDED
@@ -0,0 +1,60 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{* This is a comment block
|
2 |
+
|
3 |
+
@category Auguria
|
4 |
+
@package Auguria_Sponsorship
|
5 |
+
@author Auguria
|
6 |
+
@license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
7 |
+
|
8 |
+
Available vars in sponsorship template:
|
9 |
+
data.sender_name
|
10 |
+
data.sender_email
|
11 |
+
data.subject
|
12 |
+
data.html_message
|
13 |
+
data.text_message
|
14 |
+
data.html_footer
|
15 |
+
data.text_footer
|
16 |
+
data.recipient_email
|
17 |
+
data.sponsorship_url
|
18 |
+
|
19 |
+
*}<!--@subject {{var data.subject}} @-->
|
20 |
+
{{var data.text_message}}
|
21 |
+
{{var data.text_footer}}
|
22 |
+
|
23 |
+
--BOUNDARY_TEXT_OF_CHOICE_FOR_AUGURIA_SPONSORSHIP
|
24 |
+
|
25 |
+
<style type="text/css">
|
26 |
+
body,td { color:#2f2f2f; font:11px/1.35em Verdana, Arial, Helvetica, sans-serif; }
|
27 |
+
</style>
|
28 |
+
|
29 |
+
<div style="font:11px/1.35em Verdana, Arial, Helvetica, sans-serif;">
|
30 |
+
<table cellspacing="0" cellpadding="0" border="0" width="98%" style="margin-top:10px; font:11px/1.35em Verdana, Arial, Helvetica, sans-serif; margin-bottom:10px;">
|
31 |
+
<tr>
|
32 |
+
<td align="center" valign="top">
|
33 |
+
<!-- [ header starts here] -->
|
34 |
+
<table cellspacing="0" cellpadding="0" border="0" width="650">
|
35 |
+
<tr>
|
36 |
+
<td valign="top">
|
37 |
+
<a href="{{var data.sponsorship_url}}">
|
38 |
+
<img src="{{skin url="images/logo_email.gif" _area='frontend'}}" alt="{{var order.getStoreGroupName()}}" style="margin-bottom:10px;" border="0"/>
|
39 |
+
</a>
|
40 |
+
</td>
|
41 |
+
</tr>
|
42 |
+
</table>
|
43 |
+
|
44 |
+
</td>
|
45 |
+
</tr>
|
46 |
+
<tr>
|
47 |
+
<td align="center" valign="top">
|
48 |
+
<!-- [ middle starts here] -->
|
49 |
+
<table cellspacing="0" cellpadding="0" border="0" width="650">
|
50 |
+
<tr>
|
51 |
+
<td valign="top">
|
52 |
+
<pre>{{var data.html_message}}</pre>
|
53 |
+
<pre>{{var data.html_footer}}</pre>
|
54 |
+
</td>
|
55 |
+
</tr>
|
56 |
+
</table>
|
57 |
+
</td>
|
58 |
+
</tr>
|
59 |
+
</table>
|
60 |
+
</div>
|
js/tableorderer/table_orderer.js
ADDED
@@ -0,0 +1,574 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
// Copyright (c) 2007 Gregory SCHURGAST (http://www.negko.com, http://prototools.negko.com)
|
2 |
+
//
|
3 |
+
// Permission is hereby granted, free of charge, to any person obtaining
|
4 |
+
// a copy of this software and associated documentation files (the
|
5 |
+
// "Software"), to deal in the Software without restriction, including
|
6 |
+
// without limitation the rights to use, copy, modify, merge, publish,
|
7 |
+
// distribute, sublicense, and/or sell copies of the Software, and to
|
8 |
+
// permit persons to whom the Software is furnished to do so, subject to
|
9 |
+
// the following conditions:
|
10 |
+
//
|
11 |
+
// The above copyright notice and this permission notice shall be
|
12 |
+
// included in all copies or substantial portions of the Software.
|
13 |
+
//
|
14 |
+
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15 |
+
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16 |
+
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17 |
+
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18 |
+
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19 |
+
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20 |
+
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
21 |
+
//
|
22 |
+
// VERSION 1.2.20090611
|
23 |
+
|
24 |
+
var TableOrderer = Class.create();
|
25 |
+
//defining the rest of the class implementation
|
26 |
+
|
27 |
+
TableOrderer.prototype = {
|
28 |
+
initialize: function(element,options,msgs) {
|
29 |
+
this.element = element;
|
30 |
+
this.options = options;
|
31 |
+
this.msgs = msgs;
|
32 |
+
|
33 |
+
this.options = Object.extend({
|
34 |
+
data: false, // array of data
|
35 |
+
cols: [],
|
36 |
+
url: false, // url to a JSON application containing the data
|
37 |
+
allowMultiselect : true, // don't work yet
|
38 |
+
unsortedColumn : [], // array of column you don't want to sort
|
39 |
+
dateFormat : 'd', // d|m ; d => dd/mm/yyyy; m => mm/dd/yyyy
|
40 |
+
filter : false, // show Filter Option. false | 'top' | 'bottom'
|
41 |
+
pageCount : 5, // Number of items by table
|
42 |
+
paginate : false, // show Paginate Option. false | 'top' | 'bottom'
|
43 |
+
search : false
|
44 |
+
}, options || {});
|
45 |
+
|
46 |
+
// saves tool state data for pagination, filtering and searching.
|
47 |
+
this.tools = {
|
48 |
+
page: 1, // for pagination
|
49 |
+
pages: 1, // for pagination
|
50 |
+
filterCol: '', // for filtering
|
51 |
+
filterData: '', // for filtering
|
52 |
+
searchData: '' // for global searching
|
53 |
+
};
|
54 |
+
|
55 |
+
// separates text messages out
|
56 |
+
this.msgs = Object.extend({
|
57 |
+
loading: 'Loading...',
|
58 |
+
emptyResults: 'No matches found',
|
59 |
+
errorURL: 'invalid data',
|
60 |
+
errorData: 'no data',
|
61 |
+
searchLabel: 'Search : ',
|
62 |
+
filterLabel: 'Filter Column : ',
|
63 |
+
paginationOf: ' of ',
|
64 |
+
paginationPages: ' pages ',
|
65 |
+
paginationFirst: '<<',
|
66 |
+
paginationPrev: '<',
|
67 |
+
paginationNext: '>',
|
68 |
+
paginationLast: '>>'
|
69 |
+
}, msgs || {});
|
70 |
+
|
71 |
+
this.cache = []; // for caching capabilities
|
72 |
+
this.isCached = false; // for caching capabilities
|
73 |
+
this.container = $(element);
|
74 |
+
this.orderField = false;
|
75 |
+
this.order = 'asc';
|
76 |
+
this.thClickbfx = this.thClick.bindAsEventListener(this);
|
77 |
+
this.thOverbfx = this.thOver.bindAsEventListener(this);
|
78 |
+
this.thOutbfx = this.thOut.bindAsEventListener(this);
|
79 |
+
this.setData();
|
80 |
+
|
81 |
+
},
|
82 |
+
|
83 |
+
// clearCache -- Replaces this.cache with orginal data loaded into the table.
|
84 |
+
clearCache : function() {
|
85 |
+
this.isCached = false;
|
86 |
+
this.cache = this.data;
|
87 |
+
|
88 |
+
// Clearing the cache does not clear any ordering done on the data,
|
89 |
+
// just operations that remove records from the user's view (i.e. filtering)
|
90 |
+
if(this.orderField) {
|
91 |
+
this.orderData(this.orderField);
|
92 |
+
if (this.order == 'desc') { this.cache = this.cache.reverse(); }
|
93 |
+
}
|
94 |
+
},
|
95 |
+
|
96 |
+
// preform -- performs any inital operations needed to create the table after the data has been loaded.
|
97 |
+
perform : function(){
|
98 |
+
this.tools.pages = Math.ceil(this.cache.size() / this.options.pageCount);
|
99 |
+
this.setColumnsName();
|
100 |
+
this.clearCache();
|
101 |
+
this.createTable();
|
102 |
+
},
|
103 |
+
|
104 |
+
// getData -- gets table data from a @url. The header response from the URL must be application/json
|
105 |
+
// param url: URL from where the total table data resides.
|
106 |
+
getData : function(url){
|
107 |
+
var transmit = new Ajax.Request(url,{
|
108 |
+
onLoading : function(){ $(this.element).update(this.msgs.loading); }.bind(this),
|
109 |
+
onSuccess: function(transport) {
|
110 |
+
this.data = transport.responseJSON;
|
111 |
+
this.perform();
|
112 |
+
}.bind(this),
|
113 |
+
onFailure : function(){ alert(this.msgs.errorURL); }
|
114 |
+
});
|
115 |
+
},
|
116 |
+
|
117 |
+
// setData -- determines if the data is coming from a URL or from a json string on the page.
|
118 |
+
setData : function(){
|
119 |
+
if (!this.options.data && !this.options.url){alert(this.msgs.errorData);}
|
120 |
+
this.data = this.options.data ? this.options.data : false;
|
121 |
+
if(this.data) { this.perform(); } else { this.getData(this.options.url); }
|
122 |
+
},
|
123 |
+
|
124 |
+
// orderRule -- determines if @s is a date
|
125 |
+
// param s: string representing column data
|
126 |
+
orderRule : function (s){
|
127 |
+
var dateRE = /^(\d{2})[\/\- ](\d{2})[\/\- ](\d{4}|\d{2})/;
|
128 |
+
var exp=new RegExp(dateRE);
|
129 |
+
if ( exp.test(s) ){
|
130 |
+
s = this.options.dateFormat == 'd' ? s.replace(dateRE,"$3$2$1") : s.replace(dateRE,"$3$1$2");
|
131 |
+
}
|
132 |
+
return s;
|
133 |
+
},
|
134 |
+
|
135 |
+
// defineOrderField -- keeps track of previous orderField columns and sets the current orderField through the triggering element's id.
|
136 |
+
// param e: the event object created that triggered this method
|
137 |
+
defineOrderField : function(e){
|
138 |
+
this.previousOrderField = this.orderField;
|
139 |
+
this.orderField = Event.element(e).id.replace(this.table.id+'-','');
|
140 |
+
},
|
141 |
+
|
142 |
+
/* if you click on a header for the first time order is ascending
|
143 |
+
else it switches between ascending and descending
|
144 |
+
*/
|
145 |
+
// defineOrder -- determines what the order of the data should be
|
146 |
+
defineOrder : function(){
|
147 |
+
if (this.previousOrderField == this.orderField){ this.order = this.order == 'desc' ? 'asc' : 'desc'; }
|
148 |
+
else { this.order = 'asc'; }
|
149 |
+
},
|
150 |
+
|
151 |
+
/* Ordonne les donn�es du tableau */
|
152 |
+
// orderData -- sorts the table's cache by the @order given it.
|
153 |
+
// param order: defines the order that the data should be as ascending (asc) or descending (desc)
|
154 |
+
orderData : function(order){
|
155 |
+
this.cache = this.cache.sortBy(function(s){
|
156 |
+
var v = Object.values(s)[Object.keys(s).indexOf(order)];
|
157 |
+
return this.orderRule(v);
|
158 |
+
}.bind(this));
|
159 |
+
},
|
160 |
+
|
161 |
+
// thClick -- event handler for when the user clicks on the th cell of the table. It orders the table data by that column's field.
|
162 |
+
// param e: event that triggered handler.
|
163 |
+
thClick : function(e){
|
164 |
+
this.defineOrderField(e);
|
165 |
+
this.defineOrder();
|
166 |
+
this.orderData(this.orderField);
|
167 |
+
|
168 |
+
if (this.order == 'desc') { this.cache = this.cache.reverse(); }
|
169 |
+
|
170 |
+
this.updateTable();
|
171 |
+
},
|
172 |
+
|
173 |
+
// thOver -- event handler for when the user's mouse goes over the th cell.
|
174 |
+
// param e: event that triggered handler
|
175 |
+
thOver : function(e){
|
176 |
+
Event.element(e).addClassName('on');
|
177 |
+
},
|
178 |
+
|
179 |
+
// thOut -- event handler for when the user's mouse moves out of the th cell.
|
180 |
+
// param e: event that triggered handler
|
181 |
+
thOut : function(e){
|
182 |
+
Event.element(e).removeClassName('on');
|
183 |
+
},
|
184 |
+
|
185 |
+
// trClick -- event handler for when user clicks on a table row, highlighting the row
|
186 |
+
// param e: event that triggered handler
|
187 |
+
trClick : function(e){
|
188 |
+
this.setSelected(Event.findElement(e,'tr'));
|
189 |
+
var selected;
|
190 |
+
var items = Event.findElement(e,'tr').descendants().pluck('innerHTML');
|
191 |
+
var json = '{';
|
192 |
+
var keys = Object.keys(this.model);
|
193 |
+
|
194 |
+
items.each(function(i,index){
|
195 |
+
json += index === 0 ? '' : ', ';
|
196 |
+
json += '"'+keys[index]+'": "'+i+'"';
|
197 |
+
});
|
198 |
+
json += '}';
|
199 |
+
selected = json.evalJSON();
|
200 |
+
},
|
201 |
+
|
202 |
+
// trOver -- event handler for when the user's mouse moves into a table row.
|
203 |
+
// param e: event that triggered handler
|
204 |
+
trOver : function(e){
|
205 |
+
Event.findElement(e,'tr').addClassName('on');
|
206 |
+
},
|
207 |
+
|
208 |
+
// trOut -- event handler for when the user's mouse moves out of a table row.
|
209 |
+
// param e: event that triggered handler
|
210 |
+
trOut : function(e){
|
211 |
+
Event.findElement(e,'tr').removeClassName('on');
|
212 |
+
},
|
213 |
+
|
214 |
+
// setSelected -- what to do when a table row is selected.
|
215 |
+
// param elt: the table row that is selected
|
216 |
+
setSelected : function(elt){
|
217 |
+
if (this.options.allowMultiselect){
|
218 |
+
if(elt.hasClassName('selected')) { elt.removeClassName('selected'); } else { elt.addClassName('selected'); }
|
219 |
+
}
|
220 |
+
else{
|
221 |
+
/* */
|
222 |
+
}
|
223 |
+
},
|
224 |
+
|
225 |
+
// addToolsObserver -- binds the event handlers to the events associated with tools only
|
226 |
+
addToolsObserver : function(){
|
227 |
+
var tid = this.table.id;
|
228 |
+
|
229 |
+
if (this.options.filter){
|
230 |
+
var filterDatakbfx = this.filterData.bindAsEventListener(this);
|
231 |
+
Event.observe(tid+'-filter-column','change',filterDatakbfx);
|
232 |
+
Event.observe(tid+'-filter-data','keyup',filterDatakbfx);
|
233 |
+
}
|
234 |
+
|
235 |
+
if (this.options.search){
|
236 |
+
var searchDatakbfx = this.searchData.bindAsEventListener(this);
|
237 |
+
Event.observe(tid+'-search-data','keyup',searchDatakbfx);
|
238 |
+
}
|
239 |
+
|
240 |
+
if(this.options.paginate){
|
241 |
+
var pagerDatabfx = this.pagerData.bindAsEventListener(this);
|
242 |
+
Event.observe(tid + '-page-prev', 'click', pagerDatabfx);
|
243 |
+
Event.observe(tid + '-page-next', 'click', pagerDatabfx);
|
244 |
+
Event.observe(tid + '-page-last', 'click', pagerDatabfx);
|
245 |
+
Event.observe(tid + '-page-first', 'click', pagerDatabfx);
|
246 |
+
}
|
247 |
+
},
|
248 |
+
|
249 |
+
// addTableObserver -- binds event handlers to the events associated with the table generated.
|
250 |
+
addTableObserver : function() {
|
251 |
+
var tid = this.table.id;
|
252 |
+
$$('#'+tid+' th')
|
253 |
+
.invoke('observe','click',this.thClickbfx)
|
254 |
+
.invoke('observe','mouseover',this.thOverbfx)
|
255 |
+
.invoke('observe','mouseout',this.thOutbfx);
|
256 |
+
|
257 |
+
$$('#'+tid+' tr.data')
|
258 |
+
.invoke('observe','click',this.trClick.bindAsEventListener(this))
|
259 |
+
.invoke('observe','mouseover',this.trOver.bindAsEventListener(this))
|
260 |
+
.invoke('observe','mouseout',this.trOut.bindAsEventListener(this));
|
261 |
+
},
|
262 |
+
|
263 |
+
// Two approaches to filtering:
|
264 |
+
// 1. If pagination is turned ON then we just recreate the rows using updateTable. Somewhat costly due to creating new elements but hopefully offset by a smaller amount of rows being shown.
|
265 |
+
// 2. If pagination is turned OFF then go the slick way of just hiding the rows, which is much faster.
|
266 |
+
//
|
267 |
+
// filterData -- handler for filtering data. Updates this.tools internal state information for the filter tool and updates the table. Tried optimizing it as much as possible.
|
268 |
+
// param e: the event triggering handler
|
269 |
+
filterData : function(e){
|
270 |
+
var tid = this.table.id;
|
271 |
+
var caller = Event.element(e);
|
272 |
+
|
273 |
+
if(caller.id == tid + '-filter-column' && this.tools.filterData === ''){
|
274 |
+
this.tools.filterCol = $F(tid + '-filter-column');
|
275 |
+
return; // if we are just changing the column option and we had not filtered previously then just update the column info.
|
276 |
+
}
|
277 |
+
|
278 |
+
// Update state information for filter tool.
|
279 |
+
this.tools.filterData = $F(tid + '-filter-data');
|
280 |
+
if(caller.id == tid + '-filter-column') {
|
281 |
+
// clear filter data when changing which column we are filtering on.
|
282 |
+
$(tid + '-filter-data').clear();
|
283 |
+
this.tools.filterCol = $F(tid + '-filter-column');
|
284 |
+
this.tools.filterData = '';
|
285 |
+
}
|
286 |
+
|
287 |
+
// Anytime we filter there is a good chance our data view will change.
|
288 |
+
this.clearCache();
|
289 |
+
|
290 |
+
if(this.options.paginate) {
|
291 |
+
this.updateTable();
|
292 |
+
return;
|
293 |
+
}
|
294 |
+
|
295 |
+
$$('#'+tid+' td.' + tid+'-column-'+this.tools.filterCol).each(function(i){
|
296 |
+
i.ancestors()[1].show();
|
297 |
+
if(!i.innerHTML.toUpperCase().include(this.tools.filterData.toUpperCase())){
|
298 |
+
i.ancestors()[1].hide();
|
299 |
+
}
|
300 |
+
});
|
301 |
+
},
|
302 |
+
|
303 |
+
// pagerData -- handler for pagination. This is modifies the internal state of this.tools for pagination and then updates the table. It supports first, last, next and previous operations on the pages.
|
304 |
+
// param e: the event that triggered the handler
|
305 |
+
pagerData : function(e){
|
306 |
+
var tid = this.table.id;
|
307 |
+
var caller = Event.element(e);
|
308 |
+
|
309 |
+
switch(caller.id) {
|
310 |
+
case tid+'-page-next':
|
311 |
+
this.tools.page = ((++this.tools.page) > this.tools.pages) ? --this.tools.page : this.tools.page;
|
312 |
+
break;
|
313 |
+
case tid+'-page-prev':
|
314 |
+
this.tools.page = ((--this.tools.page) > this.tools.pages) ? ++this.tools.page : this.tools.page;
|
315 |
+
break;
|
316 |
+
case tid+'-page-last':
|
317 |
+
this.tools.page = this.tools.pages;
|
318 |
+
break;
|
319 |
+
default:
|
320 |
+
this.tools.page = 1;
|
321 |
+
}
|
322 |
+
this.updateTable();
|
323 |
+
},
|
324 |
+
|
325 |
+
// searchData -- handler for search tool. This modifies the internal state of this.tools for search tool, clears the cache and updates the table.
|
326 |
+
// param e: the event that triggered the handler
|
327 |
+
searchData : function(e){
|
328 |
+
var tid = this.table.id;
|
329 |
+
|
330 |
+
// Update state information for search tool.
|
331 |
+
this.tools.searchData = $F(tid + '-search-data');
|
332 |
+
|
333 |
+
// Anytime we filter there is a good chance our data view will change.
|
334 |
+
this.clearCache();
|
335 |
+
|
336 |
+
this.updateTable();
|
337 |
+
},
|
338 |
+
|
339 |
+
// makeColumnUnsortable -- takes the @columnId and makes its associated th cell unclickable by removing any user visual cue that it is a sortable column
|
340 |
+
// param columnId: the name of the column (field) that will be unsortable. This the same name that is used as part of the column's id.
|
341 |
+
makeColumnUnsortable : function(columnId){
|
342 |
+
columnId = this.table.id + '-' + columnId;
|
343 |
+
$(columnId).setStyle({'backgroundImage' : 'none'});
|
344 |
+
Event.stopObserving($(columnId),'click', this.thClickbfx);
|
345 |
+
Event.stopObserving($(columnId),'mouseover', this.thOverbfx);
|
346 |
+
Event.stopObserving($(columnId),'mouseout', this.thOutbfx);
|
347 |
+
},
|
348 |
+
|
349 |
+
// makeUnsort -- cycles through each item of options.unsortedColumn and makes them unsortable.
|
350 |
+
makeUnsort : function(){
|
351 |
+
this.options.unsortedColumn.each(function(i){
|
352 |
+
if($(this.table.id + '-' + i)){ this.makeColumnUnsortable(i);}
|
353 |
+
}.bind(this));
|
354 |
+
},
|
355 |
+
|
356 |
+
// createTable -- creates the inital table being ran just once. It writes out the HTML elements for the table and tools interface (i.e. pagination).
|
357 |
+
createTable : function(){
|
358 |
+
this.container.update();
|
359 |
+
this.container.insert({ top: '<table cellspacing="0" cellpadding="0" id="data-grid-'+this.element+'" class="prototools-table"></table>' });
|
360 |
+
this.table = $('data-grid-'+this.element);
|
361 |
+
this.createTools();
|
362 |
+
this.createRows();
|
363 |
+
this.addToolsObserver();
|
364 |
+
this.addTableObserver();
|
365 |
+
this.makeUnsort();
|
366 |
+
},
|
367 |
+
|
368 |
+
// updateTable -- updates just the table data, writting out the updated rows to the user and recreating the th cells in the process.
|
369 |
+
updateTable : function(){
|
370 |
+
this.table = $('data-grid-'+this.element);
|
371 |
+
$(this.table.id).update();
|
372 |
+
this.createRows();
|
373 |
+
this.addTableObserver();
|
374 |
+
this.makeUnsort();
|
375 |
+
},
|
376 |
+
|
377 |
+
// createRow -- writes out the HTML for a row using the data in @obj and applies the correct class styles associated with its @index
|
378 |
+
// param obj: holdes the data of the row
|
379 |
+
// param index: which index row this obj is in context to the table
|
380 |
+
createRow : function(obj,index){
|
381 |
+
var line = index % 2;
|
382 |
+
var row = '<tr class="data line'+line+'" id="'+this.table.id+'-'+index+'">\n';
|
383 |
+
var values = Object.values(obj);
|
384 |
+
|
385 |
+
this.tableColumnsName.each(function(s,index){
|
386 |
+
row += '\t<td class="'+this.table.id+'-column-'+s+'">'+values[index]+'</td>\n';
|
387 |
+
}.bind(this));
|
388 |
+
row += '\n</tr>';
|
389 |
+
return row;
|
390 |
+
},
|
391 |
+
|
392 |
+
// createFirstRow -- sets up the th cells of the table
|
393 |
+
// param obj: This has not been implemented -- FOR FUTURE USE
|
394 |
+
createFirstRow : function(obj){
|
395 |
+
var row = '\n<thead>\n<tr>\n';
|
396 |
+
this.tableColumnsName.each(function(i,index){
|
397 |
+
row += '\t<th id="'+this.table.id+'-'+i+'">'+this.options.cols[index]+'</th>';
|
398 |
+
}.bind(this));
|
399 |
+
row += '\n</tr>\n</thead>\n';
|
400 |
+
this.model = Object.clone(obj); // NOT SURE WHAT THIS IS DOING.
|
401 |
+
return row;
|
402 |
+
},
|
403 |
+
|
404 |
+
// setColumnsName -- column names come from the labels in the data given to the table. Just grab the names from the first record.
|
405 |
+
setColumnsName : function(){
|
406 |
+
this.tableColumnsName = Object.keys(this.data[0]);
|
407 |
+
},
|
408 |
+
|
409 |
+
// creatFilter -- creates the HTML elements for the filter tool.
|
410 |
+
createFilter : function(obj){
|
411 |
+
var option = '';
|
412 |
+
this.tableColumnsName.each(function(i,index){
|
413 |
+
option += '\t<option value="'+i+'">'+obj.options.cols[index]+'</option>\n';
|
414 |
+
});
|
415 |
+
$(this.table.id+'-options').insert({bottom : this.msgs.filterLabel})
|
416 |
+
.insert({bottom : '<select id="'+this.table.id+'-filter-column">'+option+'</select>'})
|
417 |
+
.insert({bottom : Element('input',{'id' : this.table.id+'-filter-data'})});
|
418 |
+
|
419 |
+
this.tools.filterCol = $F(this.table.id + '-filter-column');
|
420 |
+
this.tools.filterData = $F(this.table.id + '-filter-data');
|
421 |
+
},
|
422 |
+
|
423 |
+
// createPager -- creates the HTML elements for the pagination tool
|
424 |
+
createPager : function () {
|
425 |
+
$(this.table.id+'-pager').insert({bottom : Element('input',{'id' : this.table.id+'-page-first', 'type' : 'button', 'value' : this.msgs.paginationFirst, 'class' : 'first-page-button'})})
|
426 |
+
.insert({bottom : Element('input',{'id' : this.table.id+'-page-prev', 'type' : 'button', 'value' : this.msgs.paginationPrev, 'class' : 'prev-page-button'})})
|
427 |
+
.insert({bottom : '<span id="' + this.table.id+'-page-current' + '" class="currentpage">' + this.tools.page + '</span>'})
|
428 |
+
.insert({bottom : Element('input',{'id' : this.table.id+'-page-next', 'type' : 'button', 'value' : this.msgs.paginationNext, 'class' : 'next-page-button'})})
|
429 |
+
.insert({bottom : Element('input',{'id' : this.table.id+'-page-last', 'type' : 'button', 'value' : this.msgs.paginationLast, 'class' : 'last-page-button'})})
|
430 |
+
.insert({bottom : this.msgs.paginationOf + '<span id="' + this.table.id + '-page-total' + '" class="totalpages">' + this.tools.pages + '</span>' + this.msgs.paginationPages});
|
431 |
+
},
|
432 |
+
|
433 |
+
// createSearch -- creates the HTML elements for the search tool
|
434 |
+
createSearch : function(){
|
435 |
+
$(this.table.id+'-search').insert({bottom : this.msgs.searchLabel})
|
436 |
+
.insert({bottom : Element('input',{'id' : this.table.id+'-search-data'})});
|
437 |
+
|
438 |
+
this.tools.searchData = $F(this.table.id + '-search-data');
|
439 |
+
},
|
440 |
+
|
441 |
+
// A tool is any interface that acts on the table data and not directly placed in the table that is generated.
|
442 |
+
//
|
443 |
+
// createTools -- determines if each tool is going to be displayed at all or at the top or bottom of the data table.
|
444 |
+
// this should be ran only once when the table is first created since it can be expensive to create HTML elements.
|
445 |
+
// all other times tools are updated using DOM calls. the order that each tool appears is based on where in the code it is create here.
|
446 |
+
createTools : function() {
|
447 |
+
var filterDiv, pagerDiv, searchDiv;
|
448 |
+
|
449 |
+
if (this.options.filter) {
|
450 |
+
filterDiv = new Element('div' , {'id' : this.table.id+'-options' , 'class':'prototools-options'});
|
451 |
+
if(this.options.filter == 'top') {
|
452 |
+
this.table.insert({ before : filterDiv});
|
453 |
+
filterDiv.setStyle('border-bottom : none;');
|
454 |
+
}
|
455 |
+
else {
|
456 |
+
this.table.insert({ after : filterDiv});
|
457 |
+
filterDiv.setStyle('border-top : none;');
|
458 |
+
}
|
459 |
+
this.createFilter(this);
|
460 |
+
}
|
461 |
+
|
462 |
+
if(this.options.search)
|
463 |
+
{
|
464 |
+
searchDiv = new Element('div', {'id' : this.table.id + '-search', 'class':'prototools-search'});
|
465 |
+
if(this.options.search == 'top') {
|
466 |
+
this.table.insert({ before : searchDiv});
|
467 |
+
searchDiv.setStyle('border-bottom : none;');
|
468 |
+
}
|
469 |
+
else {
|
470 |
+
this.table.insert({ after : searchDiv});
|
471 |
+
searchDiv.setStyle('border-top : none;');
|
472 |
+
}
|
473 |
+
this.createSearch();
|
474 |
+
}
|
475 |
+
|
476 |
+
if(this.options.paginate)
|
477 |
+
{
|
478 |
+
pagerDiv = new Element('div', {'id' : this.table.id + '-pager', 'class':'prototools-pager'});
|
479 |
+
if(this.options.paginate == 'top') {
|
480 |
+
this.table.insert({ before : pagerDiv});
|
481 |
+
pagerDiv.setStyle('border-bottom : none;');
|
482 |
+
}
|
483 |
+
else {
|
484 |
+
this.table.insert({ after : pagerDiv});
|
485 |
+
pagerDiv.setStyle('border-top : none;');
|
486 |
+
}
|
487 |
+
this.createPager();
|
488 |
+
}
|
489 |
+
},
|
490 |
+
|
491 |
+
// createRows -- this is really the heart of the script. createRows takes the data in this.cache passes it through the filter tool, then passes it through the search tool and
|
492 |
+
// finally paginates the results displaying (creating rows) only the current page. if no records result then a message is displayed to the user. this always uses the cache
|
493 |
+
// and never this.data directly
|
494 |
+
createRows : function(){
|
495 |
+
var line = 1;
|
496 |
+
var display, enddisplay, startdisplay, dataView, dat, col, searchStr,row, s;
|
497 |
+
|
498 |
+
// header information
|
499 |
+
this.table.insert({ top: this.createFirstRow() });
|
500 |
+
|
501 |
+
// data -> {filter} -> dataView -> {paginate} -> display
|
502 |
+
dataView = this.cache;
|
503 |
+
|
504 |
+
// if filtering is turned off or not currently being used then skip
|
505 |
+
if(this.options.filter && !this.isCached && this.tools.filterData !== '') {
|
506 |
+
col = this.tools.filterCol;
|
507 |
+
dat = this.tools.filterData.toUpperCase();
|
508 |
+
dataView = [];
|
509 |
+
|
510 |
+
dataView = this.cache.inject([], function(array, rec, index) {
|
511 |
+
if(rec[col].toString().toUpperCase().include(dat))
|
512 |
+
{
|
513 |
+
array.push(rec);
|
514 |
+
}
|
515 |
+
|
516 |
+
return array;
|
517 |
+
});
|
518 |
+
}
|
519 |
+
|
520 |
+
if(this.options.search && !this.isCached && this.tools.searchData !== '') {
|
521 |
+
dat = this.tools.searchData.toUpperCase();
|
522 |
+
|
523 |
+
dataView = dataView.inject([], function(array, value, index) {
|
524 |
+
searchStr = Object.values(value).inject('', function(acc, n) {
|
525 |
+
return acc + " " + n;
|
526 |
+
});
|
527 |
+
|
528 |
+
if(searchStr.toUpperCase().include(dat)) {
|
529 |
+
array.push(value);
|
530 |
+
}
|
531 |
+
|
532 |
+
return array;
|
533 |
+
});
|
534 |
+
}
|
535 |
+
display = dataView;
|
536 |
+
|
537 |
+
if(this.options.paginate) {
|
538 |
+
this.tools.pages = Math.ceil(dataView.size() / this.options.pageCount);
|
539 |
+
if(this.tools.page > this.tools.pages) { this.tools.page = this.tools.pages; }
|
540 |
+
if(this.tools.page < 1) { this.tools.page = 1; }
|
541 |
+
if(this.tools.pages === 0) { this.tools.page = 0; }
|
542 |
+
|
543 |
+
$(this.table.id + '-page-current').update(this.tools.page); // update current page on tool
|
544 |
+
$(this.table.id + '-page-total').update(this.tools.pages); // update total pages on tool
|
545 |
+
|
546 |
+
// Instead of displaying all just display a "paginate window" to the user.
|
547 |
+
startdisplay = this.options.pageCount * (this.tools.page - 1);
|
548 |
+
enddisplay = this.options.pageCount * this.tools.page;
|
549 |
+
display = dataView.slice(startdisplay, enddisplay);
|
550 |
+
}
|
551 |
+
|
552 |
+
display.each(function(i,index){
|
553 |
+
this.table.insert({ bottom: this.createRow(i,index) });
|
554 |
+
line = (line == 1) ? 2 : 1;
|
555 |
+
}.bind(this));
|
556 |
+
|
557 |
+
// if there are no results
|
558 |
+
if(display.size() === 0) {
|
559 |
+
s = this.tableColumnsName.size();
|
560 |
+
row = '<tr class="data line0" id="'+this.table.id+'-0">\n';
|
561 |
+
row += '\t<td class="'+this.table.id+'-column" colspan="' + s + '">'+this.msgs.emptyResults+'</td>\n';
|
562 |
+
row += '\n</tr>';
|
563 |
+
this.table.insert({ bottom: row });
|
564 |
+
}
|
565 |
+
|
566 |
+
if (this.orderField){ $( this.table.id+'-'+this.orderField).addClassName(this.order); }
|
567 |
+
|
568 |
+
// the new dataView is set as the cache
|
569 |
+
if(!this.isCached) {
|
570 |
+
this.isCached = true;
|
571 |
+
this.cache = dataView;
|
572 |
+
}
|
573 |
+
}
|
574 |
+
};
|
package.xml
ADDED
@@ -0,0 +1,34 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<package>
|
3 |
+
<name>Auguria_Sponsorship</name>
|
4 |
+
<version>1.0.1</version>
|
5 |
+
<stability>stable</stability>
|
6 |
+
<license uri="http://opensource.org/licenses/osl-3.0.php">OSL 3.0</license>
|
7 |
+
<channel>community</channel>
|
8 |
+
<extends/>
|
9 |
+
<summary>This module allows customers to earn fidelity and sponsorship points.
|
10 |
+
Customers can invit friends on your site and when their friends buy products, they earn sponsorship points. If a godchild sponsor a person, the sponsor will earn a percentage too.
|
11 |
+
When customers buy, they can win fidelity points.
|
12 |
+
These points can then be exchanged against cash, discounts or gifts (not yet implemented).</summary>
|
13 |
+
<description>The module consists of :
|
14 |
+
- A form to send invitations: when an invitation is sent, the guest mail is registered , and the customer id too.
|
15 |
+
- A system of affiliation: The link sent through invitations refer to a controller that will create a cookie and a session to identify a person invited. We can equally put such links on third party sites.
|
16 |
+
- Account creation: When creating an account, it checks whether an invitation was sent to the email used for registration. If this is not the case, we check if a session cookie or affiliation exists. If there is a link, the user who registers become the godson of the customer who invits him.
|
17 |
+
- A monitoring points for the client: the client have an interface for monitoring points in his account. He can see his godson. He can ask for trade his points.
|
18 |
+
- Increment of points: Fidelity points and sponsorship points are inserted in the command, at the checkout cart. Upon payment of the command, points are awarded to customers.
|
19 |
+
- Definition of rules: the management of points can be made through the catalog rules prices or cart rules prices.
|
20 |
+
- Module configuration: The administration interface allows you to enable or disable fidelity points or sponsorship points. Enabling or no exchange of cash, gift or coupon. You can also define the max cash without siret number, the period of calcul of the max cash, if an order is required to sponsor, the period of validity for an invitation, the period of validity of a sponsorship whithout an order, number of levels for sponsorship calculation points, the percentage on indirect sponsorship sales, the maximum number of invitations that you can send per hour, the header message, the body message and the footer message.
|
21 |
+
- An administration interface: allows to see the list of invitations sent, monitor requests for trade of points.
|
22 |
+
|
23 |
+
Once installed, you must:
|
24 |
+
- Create one or several catalog or cart rules for increment fidelity and sponsorship points
|
25 |
+
- Edit CMS Page on sponsorship information
|
26 |
+
- If you enable automatic sponsorship recall, activate magento cron</description>
|
27 |
+
<notes>If you have ideas for improvements or find bugs, please send them to Franck Charpentier at www.auguria.net, with Auguria LastReviews as part of the subject line.</notes>
|
28 |
+
<authors><author><name>Auguria</name><user>auto-converted</user><email>magento@auguria.net</email></author></authors>
|
29 |
+
<date>2010-06-07</date>
|
30 |
+
<time>08:42:55</time>
|
31 |
+
<contents><target name="magedesign"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="layout"><file name="sponsorship.xml" hash="6e2160aad7460856353fe291d000a39c"/></dir></dir></dir></dir><dir name="frontend"><dir name="default"><dir name="default"><dir name="layout"><file name="sponsorship.xml" hash="2cd6dd0e36f46f79ddb0f41903cf32cf"/></dir><dir name="template"><dir name="sponsorship"><dir name="customer"><dir name="account"><dir name="dashboard"><file name="fidelity_points.phtml" hash="41131e636284b1a2dcdbc79be86c6768"/><file name="sponsor_points.phtml" hash="a510e2612ffc9730644e21924603e190"/></dir><file name="dashboard.phtml" hash="b3c531f03302819338ebd9739b144d5f"/><file name="fidelitypointsdetail.phtml" hash="ac569b80b7dfda7412a265e88e51d403"/><file name="sponsorpointsdetail.phtml" hash="0a45d3ef02a05607ea46dedb631359c6"/></dir><dir name="form"><dir name="pointschange"><file name="pointschange_cash.phtml" hash="d181ffed79eec08a0a65e78e3aa731f8"/><file name="pointschange_coupon.phtml" hash="88870799ae481ba3a62209042aa4344d"/><file name="pointschange_gift.phtml" hash="29a244c931252894b98e1a9bf1c40fc4"/></dir><file name="boost.phtml" hash="c81f986b3a40771f9652a5b9f264ba20"/><file name="edit.phtml" hash="4a55e415cf16a47c584bcbbba570d8a5"/><file name="pointschange.phtml" hash="98fced0f1ac113b79e14521fea151afc"/><file name="register.phtml" hash="52b5e45974ecf7898851b2983c496297"/></dir><dir name="widget"><file name="name.phtml" hash="167d0c09817b6a786e017e54c7117a76"/><file name="virement.phtml" hash="275ebb5903affe9462a1307cec452053"/></dir></dir><file name="sponsorship.phtml" hash="7ae1e5221b5055c2954a5416e33e4fa8"/></dir></dir></dir></dir></dir></target><target name="mage"><dir name="app"><dir name="etc"><dir name="modules"><file name="Auguria_Sponsorship.xml" hash="2ace21d88c17b2636514543e866169eb"/></dir></dir></dir><dir name="js"><dir name="tableorderer"><file name="table_orderer.js" hash="f23c21e5031d7218f83c9117cf7442eb"/></dir></dir></target><target name="magecommunity"><dir name="Auguria"><dir name="Sponsorship"><dir name="Block"><dir name="Adminhtml"><dir name="Change"><dir name="Edit"><dir name="Tab"><file name="Form.php" hash="cd94427577e45107683ea305a557f9d8"/></dir><file name="Form.php" hash="ae7412b583874b8fffc05cc3897f1a2b"/><file name="Tabs.php" hash="14027188a77ed427a54211d61471c962"/></dir><file name="Edit.php" hash="5c266273137c23f763d39d93f5ef82b4"/><file name="Grid.php" hash="9962a69732ae93157eb99ff663608203"/></dir><dir name="Link"><dir name="Edit"><dir name="Tab"><file name="Form.php" hash="98a2a13987cb165ee5233dcef0927daa"/></dir><file name="Form.php" hash="e6e087ae96b24d4edbe9e1f578e7a55a"/><file name="Tabs.php" hash="7d67a25094cf51ced551a8b3e21155c1"/></dir><file name="Edit.php" hash="bb82a0a9cd963648d7e6e34c616a0122"/><file name="Grid.php" hash="80d52f01c060d2c3b3b79c820adf8f16"/></dir><dir name="Sponsorship"><dir name="Edit"><dir name="Tab"><file name="Form.php" hash="686b9a9a14d57e0f2e7edcf3d4e0416a"/></dir><file name="Form.php" hash="a3a2352db1c72663af0caa289287a9d2"/><file name="Tabs.php" hash="257863f6b317e37110dacc86b783565b"/></dir><file name="Edit.php" hash="40ea8077f12545878ddc0cd0ad2f8cad"/><file name="Grid.php" hash="83a98d5005f4b89dfa275ddea3355c16"/></dir><file name="Change.php" hash="e5cd05ce0f684c462ec3b757982e0c97"/><file name="Link.php" hash="596e2a5247d5f8c1848cb612e15e68c0"/><file name="Sponsorship.php" hash="0ae7db005eaa0481735f41061bff5122"/></dir><dir name="Customer"><dir name="Account"><file name="PointsDetail.php" hash="365a9fc8dfc660fcef3dbbe0a131d289"/></dir><dir name="Form"><file name="Boost.php" hash="33cd49ab1ceed2816feb1d45b1c7a69b"/><file name="PointsChange.php" hash="92a71fe4f081b6c3b85cc645419fac04"/></dir><dir name="Widget"><file name="Name.php" hash="3c82b2d67f219ae56ac37526f72268fe"/><file name="Virement.php" hash="ba25badce7295811fe5deeafa284c114"/></dir></dir><dir name="Promo"><dir name="Catalog"><dir name="Edit"><dir name="Tab"><file name="Actions.php" hash="f5926196fd291cb45c13b5a8e1c018b6"/></dir></dir></dir><dir name="Quote"><dir name="Edit"><dir name="Tab"><file name="Actions.php" hash="4ff4de9b5e4d5200111d602625f91362"/></dir></dir></dir></dir><file name="Sponsorship.php" hash="a2fc28dc91b74e3bb51df20efe599522"/></dir><dir name="controllers"><dir name="Adminhtml"><file name="ChangeController.php" hash="73c1db83413cdf077562f8fb8d4bd8ec"/><file name="LinkController.php" hash="8f6c0efd94f22c15ffd2dd0f287a0e5e"/><file name="SponsorshipController.php" hash="fff66a866f773ed8f6d3708c9e0d644f"/></dir><dir name="Customer"><file name="AccountController.php" hash="2986c03548b6ff85c2ba016dea953598"/></dir><file name="BoostController.php" hash="c23cca5dfd34c8975f785e7973aa4d79"/><file name="FidelitypointsController.php" hash="7911af35af4a33da338f6d9db0f6b224"/><file name="IndexController.php" hash="6a0d89d1acf6529dc56cf7eb73db5f6b"/><file name="SponsorController.php" hash="695e53a80e094e7d5bfe2fde8eb45bb2"/><file name="SponsorpointsController.php" hash="71a221400c548c44d73a4715078ec51a"/></dir><dir name="etc"><file name="config.xml" hash="3c2623e5d74aa87a73b097b1f54f7e12"/><file name="system.xml" hash="25a9635ec75e9fdabae08d9c47aec44b"/></dir><dir name="Helper"><file name="Data.php" hash="10e2e7c3408665a07464cd6c20bf1550"/><file name="Mail.php" hash="867081c98161687a1e9d502fb23473d0"/></dir><dir name="Lib"><file name="Html2Text.php" hash="4bd5cf3bd59121ffa9d15b9a60a56ca4"/></dir><dir name="Model"><dir name="Adminhtml"><dir name="System"><dir name="Config"><dir name="Backend"><dir name="Sponsorship"><file name="Entier.php" hash="cb45db31cab4b797103d686e03404d6d"/><file name="Float.php" hash="35b76ecdc9065ae9aef1acdee66ab57c"/></dir></dir></dir></dir></dir><dir name="Core"><dir name="Email"><file name="Template.php" hash="5ad7985013fff5f28cd76bbec0a71c22"/></dir></dir><dir name="Customer"><file name="Customer.php" hash="1ee0fbe7c2ce96fac9f7dfc97e179a9e"/></dir><dir name="Mysql4"><dir name="CatalogFidelityPoint"><file name="Collection.php" hash="b151b96d8370ea1fe9e309559fb04573"/></dir><dir name="CatalogSponsorPoint"><file name="Collection.php" hash="a56b2950a04ae446dcf82ad4bdfadb07"/></dir><dir name="Change"><file name="Collection.php" hash="99a67418cc7b573f285c04a5d7f6020d"/></dir><dir name="FidelityLog"><file name="Collection.php" hash="7230b303a336da8167709168410c0531"/></dir><dir name="Sponsorlog"><file name="Collection.php" hash="8efa2fb23ec7a6ad2373395ff4739f1e"/></dir><dir name="Sponsorship"><file name="Collection.php" hash="bea288d9bdc6faee88795895eb5bd6ee"/></dir><file name="CatalogFidelityPoint.php" hash="ab4402569102622be8264d135768afbc"/><file name="CatalogSponsorPoint.php" hash="f34d98e76da49afe1e2049dcb3c73626"/><file name="Change.php" hash="fcc6ad58aae6b4051fa997c03b5b5756"/><file name="Fidelitylog.php" hash="47a37a5374c82d3428a6bcc301316ce8"/><file name="Rule.php" hash="2ee2d8879d6ac0be3432e1e5334d77cf"/><file name="Sponsorlog.php" hash="97bde1eef9156b5a20f5f2f92a6fee03"/><file name="Sponsorship.php" hash="2c6d63261112e53a9c442ea3568e2e32"/></dir><file name="AutoBoost.php" hash="5b2527368d08cade3495819a823ff8f7"/><file name="Change.php" hash="c4e3f0cd6077fab4ebc7e078d031fc3d"/><file name="Changestatut.php" hash="21106c8021072b8f8cf8419fec0ad0a9"/><file name="EmptyPHP.php" hash="e4375ede533ff3a0500d327e14b7ff54"/><file name="Fidelitylog.php" hash="1644dc508b0a1c4d06397a48509f652c"/><file name="Observer.php" hash="6455d60700e344fb7fb23213951be5e6"/><file name="Sponsorlog.php" hash="834b0e8e29eff5061abb18621a22ddb5"/><file name="Sponsorship.php" hash="acd91d3c6a6dbe801e7dde41a8d2fb06"/><file name="Status.php" hash="ad5779cf7a0887635315b74827780063"/><file name="Validator.php" hash="87d39a07bff5133894f8334f9f5fe967"/></dir><dir name="sql"><dir name="sponsorship_setup"><file name="mysql4-install-0.1.0.php" hash="cde2a97370601a046bcc559e22a7cdb8"/><file name="mysql4-upgrade-0.1.0-0.1.1.php" hash="99c4e9b7ab6d3aab2477195310482242"/><file name="mysql4-upgrade-0.1.1-0.1.2.php" hash="08dc31268dcb35b68abbc4c179f7ed03"/><file name="mysql4-upgrade-0.1.2-0.1.3.php" hash="9966b88c1e297dd4cae297859e4034a0"/><file name="mysql4-upgrade-0.1.3-0.1.4.php" hash="0d55e5801c8e4031aeece7787ffc94c1"/><file name="mysql4-upgrade-0.1.4-0.1.5.php" hash="6de811c47e0031c134a8343e230ca451"/><file name="mysql4-upgrade-0.1.5-0.1.6.php" hash="d6f43e969bf07f5859b1f251540c358d"/><file name="mysql4-upgrade-0.1.6-0.1.7.php" hash="5289d74fa889d0046a19d9714df5572b"/><file name="mysql4-upgrade-0.1.7-0.1.8.php" hash="89acdec2f7785fc2e6e82ff6265e439a"/><file name="mysql4-upgrade-0.1.8-0.1.9.php" hash="02158b6524f5d24c8e9d07022da2aa27"/><file name="mysql4-upgrade-0.1.9-0.1.10.php" hash="b29284b6cf0df556810ed3bdb47fd7dc"/></dir></dir></dir></dir></target><target name="magelocale"><dir name="en_US"><dir name="template"><dir name="email"><file name="sponsorship_coupon.html" hash="0ca5d0c23070e0a6a9f9822ad9612678"/><file name="sponsorship_invitation.html" hash="30fe91c3b83ee223f6bffb3dd779dd26"/></dir></dir></dir><dir name="fr_FR"><dir name="template"><dir name="email"><file name="sponsorship_coupon.html" hash="bbd873e171d6a9ca5f46e04314c39624"/><file name="sponsorship_invitation.html" hash="30fe91c3b83ee223f6bffb3dd779dd26"/></dir></dir><file name="Auguria_Sponsorship.csv" hash="d859fc335ff27d074ba862db5d616a57"/></dir></target><target name="mageskin"><dir name="frontend"><dir name="default"><dir name="default"><dir name="css"><file name="tableorderer.css" hash="30454132306ff6ac4dcf190aa922b7cc"/></dir><dir name="images"><dir name="tableorderer"><file name="asc.gif" hash="a54846803de3cc786eec3d69f9ac2d38"/><file name="bg.gif" hash="c01ad2e7c59d1a20a433cb873c21bd88"/><file name="bkg_toolbar.gif" hash="fb7ed019476eaa1643af922b59ede4fb"/><file name="desc.gif" hash="f8a1940c9cf44ab8870319169f3a14ff"/></dir></dir></dir></dir></dir></target></contents>
|
32 |
+
<compatible/>
|
33 |
+
<dependencies/>
|
34 |
+
</package>
|
skin/frontend/default/default/css/tableorderer.css
ADDED
@@ -0,0 +1,74 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
/*TAB SORTER *//*
|
2 |
+
table.pager select,
|
3 |
+
table.view-by select { margin:0 3px; font-size:.95em; }
|
4 |
+
table.pager select { width:50px; }
|
5 |
+
table.view-by td.sort-by { text-align:right; padding-right:44px; }
|
6 |
+
table.view-by select { width:85px; }
|
7 |
+
table.pager, table.view-by {
|
8 |
+
width:100%;
|
9 |
+
background:url(../images/pager_bg.gif) repeat-x 0 100% #fff;
|
10 |
+
font-size:.95em;
|
11 |
+
}
|
12 |
+
table.pager td {
|
13 |
+
width:32%;
|
14 |
+
border-top:1px solid #eee;
|
15 |
+
padding:4px 8px;
|
16 |
+
vertical-align:middle;
|
17 |
+
}
|
18 |
+
table.pager td.pages { padding:4px 0; white-space:nowrap; text-align:center; }
|
19 |
+
table.pager ol, table.pager li {
|
20 |
+
display:inline;
|
21 |
+
}
|
22 |
+
table.pager li { padding:0 2px; }
|
23 |
+
table.view-by td {
|
24 |
+
width:33%;
|
25 |
+
border-top:1px solid #e2e2e2;
|
26 |
+
padding:4px 8px;
|
27 |
+
vertical-align:middle;
|
28 |
+
}
|
29 |
+
*/
|
30 |
+
|
31 |
+
.prototools-table{ width:100%; text-align:center; font-size:12px; border:1px solid #bebcb7; }
|
32 |
+
.prototools-table th{
|
33 |
+
margin:0;
|
34 |
+
cursor:pointer;
|
35 |
+
background-position:right center;
|
36 |
+
background-repeat:no-repeat;
|
37 |
+
background-image:url(../images/tableorderer/bg.gif);
|
38 |
+
border-right:1px solid #c2d3e0;
|
39 |
+
color:#0a263c;
|
40 |
+
padding : 2px 18px;
|
41 |
+
text-align:center;
|
42 |
+
}
|
43 |
+
|
44 |
+
.prototools-table thead tr { background:url(../images/bkg_th.gif) repeat-x 0 100% #d9e5ee; }
|
45 |
+
|
46 |
+
.prototools-table th.desc{background-image:url('../images/tableorderer/desc.gif'); }
|
47 |
+
.prototools-table th.asc{background-image:url('../images/tableorderer/asc.gif'); }
|
48 |
+
.prototools-table th.on{ cursor :pointer;}
|
49 |
+
|
50 |
+
.prototools-table td { border-bottom:1px solid #d9dde3; border-right:1px solid #d9dde3; padding : 6px; }
|
51 |
+
|
52 |
+
.prototools-table tr.line0{ background:#f8f7f5; }
|
53 |
+
.prototools-table tr.line1{ background:#eeeded; }
|
54 |
+
/*.prototools-table tr.on{ background-color:#CDDBDC; }*/
|
55 |
+
.prototools-table tr.selected{ background-color:#E4E4E4; }
|
56 |
+
|
57 |
+
div.prototools-options { font-size:12px; padding :5px 7px; background:url(../images/tableorderer/bkg_toolbar.gif) repeat-x 0 100% #fff;}
|
58 |
+
div.prototools-options input, div.prototools-options select{border : 1px solid #CCC; font-size:12px; padding :1px 3px; margin :0 5px;}
|
59 |
+
/*.prev-page-button {background:url(../images/login_box_form_buttons_bg.gif) }*/
|
60 |
+
|
61 |
+
div.prototools-pager { font-size:11px; padding :5px 7px; text-align:right; background:url(../images/tableorderer/bkg_toolbar.gif) repeat-x 0 100% #fff;}
|
62 |
+
div.prototools-pager .currentpage {padding-left:10px; padding-right:10px;}
|
63 |
+
div.prototools-pager .totalpages {padding:0;}
|
64 |
+
div.prototools-pager input {font-size:11px;}
|
65 |
+
|
66 |
+
div.prototools-search {border : 1px solid #E1E1E1; font-size:11px; padding :5px 7px;}
|
67 |
+
div.prototools-search input {border : 1px solid #E1E1E1; font-size:11px; margin :0 3px;}
|
68 |
+
|
69 |
+
th {font-weight:bold;}
|
70 |
+
|
71 |
+
/*Alignements spécifiques*/
|
72 |
+
.data-grid-invit-table-column-invits_name { text-align:left; }
|
73 |
+
.data-grid-invit-table-column-invits_email { text-align:left; }
|
74 |
+
.data-grid-sponsor-table-column-nom { text-align:left; }
|
skin/frontend/default/default/images/tableorderer/asc.gif
ADDED
Binary file
|
skin/frontend/default/default/images/tableorderer/bg.gif
ADDED
Binary file
|
skin/frontend/default/default/images/tableorderer/bkg_toolbar.gif
ADDED
Binary file
|
skin/frontend/default/default/images/tableorderer/desc.gif
ADDED
Binary file
|