S3ibusiness_Giftpromo - Version 0.1.2

Version Notes

If you have ideas for improvements or find bugs, please send them to Ahmed MAHI at www.s3ibusiness.com, 1hmedmahi@gmail.com

Download this release

Release Info

Developer Magento Core Team
Extension S3ibusiness_Giftpromo
Version 0.1.2
Comparing to
See all releases


Version 0.1.2

Files changed (21) hide show
  1. app/code/community/S3ibusiness/Giftpromo/Block/Adminhtml/Giftpromo.php +19 -0
  2. app/code/community/S3ibusiness/Giftpromo/Block/Adminhtml/Giftpromo/Edit.php +51 -0
  3. app/code/community/S3ibusiness/Giftpromo/Block/Adminhtml/Giftpromo/Edit/Form.php +25 -0
  4. app/code/community/S3ibusiness/Giftpromo/Block/Adminhtml/Giftpromo/Edit/Tab/Form.php +56 -0
  5. app/code/community/S3ibusiness/Giftpromo/Block/Adminhtml/Giftpromo/Edit/Tabs.php +30 -0
  6. app/code/community/S3ibusiness/Giftpromo/Block/Adminhtml/Giftpromo/Grid.php +113 -0
  7. app/code/community/S3ibusiness/Giftpromo/Helper/Data.php +12 -0
  8. app/code/community/S3ibusiness/Giftpromo/Model/Giftpromo.php +16 -0
  9. app/code/community/S3ibusiness/Giftpromo/Model/Mysql4/Giftpromo.php +16 -0
  10. app/code/community/S3ibusiness/Giftpromo/Model/Mysql4/Giftpromo/Collection.php +22 -0
  11. app/code/community/S3ibusiness/Giftpromo/Model/Observer.php +125 -0
  12. app/code/community/S3ibusiness/Giftpromo/Model/Status.php +21 -0
  13. app/code/community/S3ibusiness/Giftpromo/controllers/Adminhtml/IndexController.php +192 -0
  14. app/code/community/S3ibusiness/Giftpromo/etc/adminhtml.xml +59 -0
  15. app/code/community/S3ibusiness/Giftpromo/etc/config.xml +152 -0
  16. app/code/community/S3ibusiness/Giftpromo/etc/system.xml +44 -0
  17. app/code/community/S3ibusiness/Giftpromo/sql/giftpromo_setup/mysql4-install-0.1.0.php +20 -0
  18. app/etc/modules/S3ibusiness_Giftpromo.xml +9 -0
  19. app/locale/en_US/S3ibusiness_Giftpromo.csv +27 -0
  20. app/locale/fr_FR/S3ibusiness_Giftpromo.csv +27 -0
  21. package.xml +20 -0
app/code/community/S3ibusiness/Giftpromo/Block/Adminhtml/Giftpromo.php ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @category S3ibusiness
4
+ * @package S3ibusiness_Giftpromo
5
+ * @copyright Copyright (c) 2011 S3i Business sarl au. (http://www.s3ibusiness.com)
6
+ * @author Ahmed Mahi <1hmedmahi@gmail.com>
7
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
8
+ */
9
+ class S3ibusiness_Giftpromo_Block_Adminhtml_Giftpromo extends Mage_Adminhtml_Block_Widget_Grid_Container
10
+ {
11
+ public function __construct()
12
+ {
13
+ $this->_controller = 'adminhtml_giftpromo';
14
+ $this->_blockGroup = 'giftpromo';
15
+ $this->_headerText = Mage::helper('giftpromo')->__('Gift Manager');
16
+ $this->_addButtonLabel = Mage::helper('giftpromo')->__('Add Gift');
17
+ parent::__construct();
18
+ }
19
+ }
app/code/community/S3ibusiness/Giftpromo/Block/Adminhtml/Giftpromo/Edit.php ADDED
@@ -0,0 +1,51 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @category S3ibusiness
4
+ * @package S3ibusiness_Giftpromo
5
+ * @copyright Copyright (c) 2011 S3i Business sarl au. (http://www.s3ibusiness.com)
6
+ * @author Ahmed Mahi <1hmedmahi@gmail.com>
7
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
8
+ */
9
+ class S3ibusiness_Giftpromo_Block_Adminhtml_Giftpromo_Edit extends Mage_Adminhtml_Block_Widget_Form_Container
10
+ {
11
+ public function __construct()
12
+ {
13
+ parent::__construct();
14
+
15
+ $this->_objectId = 'id';
16
+ $this->_blockGroup = 'giftpromo';
17
+ $this->_controller = 'adminhtml_giftpromo';
18
+
19
+ $this->_updateButton('save', 'label', Mage::helper('giftpromo')->__('Save Gift'));
20
+ $this->_updateButton('delete', 'label', Mage::helper('giftpromo')->__('Delete Gift'));
21
+
22
+ $this->_addButton('saveandcontinue', array(
23
+ 'label' => Mage::helper('giftpromo')->__('Save And Continue Edit'),
24
+ 'onclick' => 'saveAndContinueEdit()',
25
+ 'class' => 'save',
26
+ ), -100);
27
+
28
+ $this->_formScripts[] = "
29
+ function toggleEditor() {
30
+ if (tinyMCE.getInstanceById('giftpromo_content') == null) {
31
+ tinyMCE.execCommand('mceAddControl', false, 'giftpromo_content');
32
+ } else {
33
+ tinyMCE.execCommand('mceRemoveControl', false, 'giftpromo_content');
34
+ }
35
+ }
36
+
37
+ function saveAndContinueEdit(){
38
+ editForm.submit($('edit_form').action+'back/edit/');
39
+ }
40
+ ";
41
+ }
42
+
43
+ public function getHeaderText()
44
+ {
45
+ if( Mage::registry('giftpromo_data') && Mage::registry('giftpromo_data')->getId() ) {
46
+ return Mage::helper('giftpromo')->__("Edit Gift '%s'", $this->htmlEscape(Mage::registry('giftpromo_data')->getGiftName()));
47
+ } else {
48
+ return Mage::helper('giftpromo')->__('Add Gift');
49
+ }
50
+ }
51
+ }
app/code/community/S3ibusiness/Giftpromo/Block/Adminhtml/Giftpromo/Edit/Form.php ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @category S3ibusiness
4
+ * @package S3ibusiness_Giftpromo
5
+ * @copyright Copyright (c) 2011 S3i Business sarl au. (http://www.s3ibusiness.com)
6
+ * @author Ahmed Mahi <1hmedmahi@gmail.com>
7
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
8
+ */
9
+ class S3ibusiness_Giftpromo_Block_Adminhtml_Giftpromo_Edit_Form extends Mage_Adminhtml_Block_Widget_Form
10
+ {
11
+ protected function _prepareForm()
12
+ {
13
+ $form = new Varien_Data_Form(array(
14
+ 'id' => 'edit_form',
15
+ 'action' => $this->getUrl('*/*/save', array('id' => $this->getRequest()->getParam('id'))),
16
+ 'method' => 'post',
17
+ 'enctype' => 'multipart/form-data'
18
+ )
19
+ );
20
+
21
+ $form->setUseContainer(true);
22
+ $this->setForm($form);
23
+ return parent::_prepareForm();
24
+ }
25
+ }
app/code/community/S3ibusiness/Giftpromo/Block/Adminhtml/Giftpromo/Edit/Tab/Form.php ADDED
@@ -0,0 +1,56 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @category S3ibusiness
4
+ * @package S3ibusiness_Giftpromo
5
+ * @copyright Copyright (c) 2011 S3i Business sarl au. (http://www.s3ibusiness.com)
6
+ * @author Ahmed Mahi <1hmedmahi@gmail.com>
7
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
8
+ */
9
+ class S3ibusiness_Giftpromo_Block_Adminhtml_Giftpromo_Edit_Tab_Form extends Mage_Adminhtml_Block_Widget_Form
10
+ {
11
+ protected function _prepareForm()
12
+ {
13
+ $form = new Varien_Data_Form();
14
+ $this->setForm($form);
15
+ $fieldset = $form->addFieldset('giftpromo_form', array('legend'=>Mage::helper('giftpromo')->__('Gift Information')));
16
+
17
+ $fieldset->addField('gift_name', 'text', array(
18
+ 'label' => Mage::helper('giftpromo')->__('Gift name'),
19
+ 'class' => 'required-entry',
20
+ 'required' => true,
21
+ 'name' => 'gift_name',
22
+ ));
23
+ $fieldset->addField('product_id', 'text', array(
24
+ 'label' => Mage::helper('giftpromo')->__('Product id'),
25
+ 'class' => 'required-entry',
26
+ 'required' => true,
27
+ 'name' => 'product_id',
28
+ ));
29
+
30
+ $fieldset->addField('status', 'select', array(
31
+ 'label' => Mage::helper('giftpromo')->__('Status'),
32
+ 'name' => 'status',
33
+ 'values' => array(
34
+ array(
35
+ 'value' => 1,
36
+ 'label' => Mage::helper('giftpromo')->__('Enabled'),
37
+ ),
38
+
39
+ array(
40
+ 'value' => 2,
41
+ 'label' => Mage::helper('giftpromo')->__('Disabled'),
42
+ ),
43
+ ),
44
+ ));
45
+
46
+
47
+ if ( Mage::getSingleton('adminhtml/session')->getGiftpromoData() )
48
+ {
49
+ $form->setValues(Mage::getSingleton('adminhtml/session')->getGiftpromoData());
50
+ Mage::getSingleton('adminhtml/session')->setGiftpromoData(null);
51
+ } elseif ( Mage::registry('giftpromo_data') ) {
52
+ $form->setValues(Mage::registry('giftpromo_data')->getData());
53
+ }
54
+ return parent::_prepareForm();
55
+ }
56
+ }
app/code/community/S3ibusiness/Giftpromo/Block/Adminhtml/Giftpromo/Edit/Tabs.php ADDED
@@ -0,0 +1,30 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @category S3ibusiness
4
+ * @package S3ibusiness_Giftpromo
5
+ * @copyright Copyright (c) 2011 S3i Business sarl au. (http://www.s3ibusiness.com)
6
+ * @author Ahmed Mahi <1hmedmahi@gmail.com>
7
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
8
+ */
9
+ class S3ibusiness_Giftpromo_Block_Adminhtml_Giftpromo_Edit_Tabs extends Mage_Adminhtml_Block_Widget_Tabs
10
+ {
11
+
12
+ public function __construct()
13
+ {
14
+ parent::__construct();
15
+ $this->setId('giftpromo_tabs');
16
+ $this->setDestElementId('edit_form');
17
+ // $this->setTitle(Mage::helper('giftpromo')->__(''));
18
+ }
19
+
20
+ protected function _beforeToHtml()
21
+ {
22
+ $this->addTab('form_section', array(
23
+ 'label' => Mage::helper('giftpromo')->__('Gift Information'),
24
+ 'title' => Mage::helper('giftpromo')->__('Gift Information'),
25
+ 'content' => $this->getLayout()->createBlock('giftpromo/adminhtml_giftpromo_edit_tab_form')->toHtml(),
26
+ ));
27
+
28
+ return parent::_beforeToHtml();
29
+ }
30
+ }
app/code/community/S3ibusiness/Giftpromo/Block/Adminhtml/Giftpromo/Grid.php ADDED
@@ -0,0 +1,113 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @category S3ibusiness
4
+ * @package S3ibusiness_Giftpromo
5
+ * @copyright Copyright (c) 2011 S3i Business sarl au. (http://www.s3ibusiness.com)
6
+ * @author Ahmed Mahi <1hmedmahi@gmail.com>
7
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
8
+ */
9
+ class S3ibusiness_Giftpromo_Block_Adminhtml_Giftpromo_Grid extends Mage_Adminhtml_Block_Widget_Grid
10
+ {
11
+ public function __construct()
12
+ {
13
+ parent::__construct();
14
+ $this->setId('giftpromoGrid');
15
+ $this->setDefaultSort('gift_id');
16
+ $this->setDefaultDir('ASC');
17
+ $this->setSaveParametersInSession(true);
18
+ }
19
+
20
+ protected function _prepareCollection()
21
+ {
22
+ $collection = Mage::getModel('giftpromo/giftpromo')->getCollection();
23
+ $this->setCollection($collection);
24
+ return parent::_prepareCollection();
25
+ }
26
+
27
+ protected function _prepareColumns()
28
+ {
29
+ $this->addColumn('gift_id', array(
30
+ 'header' => Mage::helper('giftpromo')->__('ID'),
31
+ 'align' =>'right',
32
+ 'width' => '50px',
33
+ 'index' => 'gift_id',
34
+ ));
35
+
36
+ $this->addColumn('gift_name', array(
37
+ 'header' => Mage::helper('giftpromo')->__('Gift name'),
38
+ 'align' =>'left',
39
+ 'index' => 'gift_name',
40
+ ));
41
+ $this->addColumn('status', array(
42
+ 'header' => Mage::helper('giftpromo')->__('Status'),
43
+ 'align' => 'left',
44
+ 'width' => '80px',
45
+ 'index' => 'status',
46
+ 'type' => 'options',
47
+ 'options' => array(
48
+ 1 => 'Enabled',
49
+ 2 => 'Disabled',
50
+ ),
51
+ ));
52
+
53
+ $this->addColumn('action',
54
+ array(
55
+ 'header' => Mage::helper('giftpromo')->__('Action'),
56
+ 'width' => '100',
57
+ 'type' => 'action',
58
+ 'getter' => 'getId',
59
+ 'actions' => array(
60
+ array(
61
+ 'caption' => Mage::helper('giftpromo')->__('Edit'),
62
+ 'url' => array('base'=> '*/*/edit'),
63
+ 'field' => 'id'
64
+ )
65
+ ),
66
+ 'filter' => false,
67
+ 'sortable' => false,
68
+ 'index' => 'stores',
69
+ 'is_system' => true,
70
+ ));
71
+
72
+ $this->addExportType('*/*/exportCsv', Mage::helper('giftpromo')->__('CSV'));
73
+ $this->addExportType('*/*/exportXml', Mage::helper('giftpromo')->__('XML'));
74
+
75
+ return parent::_prepareColumns();
76
+ }
77
+
78
+ protected function _prepareMassaction()
79
+ {
80
+ $this->setMassactionIdField('gift_id');
81
+ $this->getMassactionBlock()->setFormFieldName('giftpromo');
82
+
83
+ $this->getMassactionBlock()->addItem('delete', array(
84
+ 'label' => Mage::helper('giftpromo')->__('Delete'),
85
+ 'url' => $this->getUrl('*/*/massDelete'),
86
+ 'confirm' => Mage::helper('giftpromo')->__('Are you sure?')
87
+ ));
88
+
89
+ $statuses = Mage::getSingleton('giftpromo/status')->getOptionArray();
90
+
91
+ array_unshift($statuses, array('label'=>'', 'value'=>''));
92
+ $this->getMassactionBlock()->addItem('status', array(
93
+ 'label'=> Mage::helper('giftpromo')->__('Change status'),
94
+ 'url' => $this->getUrl('*/*/massStatus', array('_current'=>true)),
95
+ 'additional' => array(
96
+ 'visibility' => array(
97
+ 'name' => 'status',
98
+ 'type' => 'select',
99
+ 'class' => 'required-entry',
100
+ 'label' => Mage::helper('giftpromo')->__('Status'),
101
+ 'values' => $statuses
102
+ )
103
+ )
104
+ ));
105
+ return $this;
106
+ }
107
+
108
+ public function getRowUrl($row)
109
+ {
110
+ return $this->getUrl('*/*/edit', array('id' => $row->getId()));
111
+ }
112
+
113
+ }
app/code/community/S3ibusiness/Giftpromo/Helper/Data.php ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @category S3ibusiness
4
+ * @package S3ibusiness_Giftpromo
5
+ * @copyright Copyright (c) 2011 S3i Business sarl au. (http://www.s3ibusiness.com)
6
+ * @author Ahmed Mahi <1hmedmahi@gmail.com>
7
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
8
+ */
9
+ class S3ibusiness_Giftpromo_Helper_Data extends Mage_Core_Helper_Abstract
10
+ {
11
+
12
+ }
app/code/community/S3ibusiness/Giftpromo/Model/Giftpromo.php ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @category S3ibusiness
4
+ * @package S3ibusiness_Giftpromo
5
+ * @copyright Copyright (c) 2011 S3i Business sarl au. (http://www.s3ibusiness.com)
6
+ * @author Ahmed Mahi <1hmedmahi@gmail.com>
7
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
8
+ */
9
+ class S3ibusiness_Giftpromo_Model_Giftpromo extends Mage_Core_Model_Abstract
10
+ {
11
+ public function _construct()
12
+ {
13
+ parent::_construct();
14
+ $this->_init('giftpromo/giftpromo');
15
+ }
16
+ }
app/code/community/S3ibusiness/Giftpromo/Model/Mysql4/Giftpromo.php ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @category S3ibusiness
4
+ * @package S3ibusiness_Giftpromo
5
+ * @copyright Copyright (c) 2011 S3i Business sarl au. (http://www.s3ibusiness.com)
6
+ * @author Ahmed Mahi <1hmedmahi@gmail.com>
7
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
8
+ */
9
+ class S3ibusiness_Giftpromo_Model_Mysql4_Giftpromo extends Mage_Core_Model_Mysql4_Abstract
10
+ {
11
+ public function _construct()
12
+ {
13
+ // Note that the giftpromo_id refers to the key field in your database table.
14
+ $this->_init('giftpromo/giftpromo', 'gift_id');
15
+ }
16
+ }
app/code/community/S3ibusiness/Giftpromo/Model/Mysql4/Giftpromo/Collection.php ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @category S3ibusiness
4
+ * @package S3ibusiness_Giftpromo
5
+ * @copyright Copyright (c) 2011 S3i Business sarl au. (http://www.s3ibusiness.com)
6
+ * @author Ahmed Mahi <1hmedmahi@gmail.com>
7
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
8
+ */
9
+ class S3ibusiness_Giftpromo_Model_Mysql4_Giftpromo_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract
10
+ {
11
+ public function _construct()
12
+ {
13
+ parent::_construct();
14
+ $this->_init('giftpromo/giftpromo');
15
+ }
16
+ public function LoadGiftbyProductId( $productId )
17
+ {
18
+ $this->getSelect()->from(array(c,$this->getTable('giftpromo')))
19
+ ->where('product_id=?', $productId);
20
+ return $this;
21
+ }
22
+ }
app/code/community/S3ibusiness/Giftpromo/Model/Observer.php ADDED
@@ -0,0 +1,125 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @category S3ibusiness
4
+ * @package S3ibusiness_Giftpromo
5
+ * @copyright Copyright (c) 2011 S3i Business sarl au. (http://www.s3ibusiness.com)
6
+ * @author Ahmed Mahi <1hmedmahi@gmail.com>
7
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
8
+ */
9
+ class S3ibusiness_Giftpromo_Model_Observer
10
+ {
11
+ private $_giftsCollection;
12
+
13
+ public function __construct() {
14
+ if(Mage::getStoreConfig('giftpromo/settings/enabled')) {
15
+ $this->_giftsCollection = Mage::getModel('giftpromo/giftpromo')->getCollection();
16
+ }
17
+ }
18
+ public function deleteDiscountTitle($observer) {
19
+ $block = $observer->getEvent()->getBlock();
20
+ if($block instanceof Mage_Tax_Block_Checkout_Discount){
21
+ $blockTitle=explode(',',str_replace(')','',str_replace(' (', ',', $block->getTotal()->getTitle())));
22
+ $title=$blockTitle[0];
23
+ unset($blockTitle[0]);
24
+ foreach (explode(',',$block->getQuote()->getAppliedRuleIds()) as $appliedRuleId) {
25
+ $rule=Mage::getModel('salesrule/rule')->load($appliedRuleId);
26
+ foreach ($this->_giftsCollection as $gift){
27
+ if($rule->getSimpleAction()=='gift_product_'.$gift->getGiftId()) {
28
+ $store_labels=$rule->getStoreLabels();
29
+ $blockTitle=array_diff(array_diff(array_diff($blockTitle,array($rule->getName())),array($store_labels[0])),array($store_labels[1]));
30
+ }
31
+ }
32
+ }
33
+ $block->getTotal()->setTitle( $title.' ('.implode(",",$blockTitle).')');
34
+ }
35
+ }
36
+ public function addSimpleAction($observer) {
37
+ if(Mage::getStoreConfig('giftpromo/settings/enabled')) {
38
+ $options=array(
39
+ 'by_percent' => Mage::helper('salesrule')->__('Percent of product price discount'),
40
+ 'by_fixed' => Mage::helper('salesrule')->__('Fixed amount discount'),
41
+ 'cart_fixed' => Mage::helper('salesrule')->__('Fixed amount discount for whole cart'),
42
+ 'buy_x_get_y' => Mage::helper('salesrule')->__('Buy X get Y free (discount amount is Y)'),
43
+ );
44
+ foreach ($this->_giftsCollection as $gift){
45
+ if($gift->getProductId()&&$product=$this->getProduct($gift->getProductId())){
46
+ $options['gift_product_'.$gift->getGiftId()] = Mage::helper('giftpromo')->__("Gift : '%s'",$gift->getGiftName()/*$product->getName()*/);
47
+ }
48
+ }
49
+ $form = $observer->getForm();
50
+ $fieldset=$form->getElement('action_fieldset');
51
+ $fieldset->removeField('simple_action');
52
+ $fieldset->addField('simple_action', 'select', array(
53
+ 'label' => Mage::helper('salesrule')->__('Apply'),
54
+ 'name' => 'simple_action',
55
+ 'options' => $options,
56
+ ),'^');
57
+ }
58
+ }
59
+ public function addGiftCart($giftId){
60
+ $gift=Mage::getModel('giftpromo/giftpromo')->load($giftId);
61
+ $this->removeGifts($gift);
62
+ if($gift->getStatus()==1&&($product=$this->getProduct($gift->getProductId()))&&$product->getIsInStock()){
63
+ $cart=Mage::getSingleton('checkout/cart');
64
+ $cart->addProduct($product,-1);
65
+ $cart->init();
66
+ $cart->save();
67
+
68
+ }
69
+ }
70
+ public function addGifts($observer) {
71
+ if(Mage::getStoreConfig('giftpromo/settings/enabled')) {
72
+ $Controller = $observer->getControllerAction();
73
+ if ($Controller instanceof Mage_Checkout_CartController) {
74
+ $actionName = $Controller->getFullActionName();
75
+ $cart=Mage::getSingleton('checkout/cart');
76
+ $quote=$cart->getQuote();
77
+ $actions=array('add','addgroup','updatePost','delete','couponPost','estimateUpdatePost');
78
+ foreach ($actions as $action) {
79
+ if($actionName=='checkout_cart_'.$action){
80
+ $appliedRuleIds=$quote->getAppliedRuleIds();
81
+ $giftIds=array();
82
+ foreach (explode(',',$appliedRuleIds) as $appliedRuleId) {
83
+ $simpleAction=$rule = Mage::getModel('salesrule/rule')
84
+ ->load($appliedRuleId)->getSimpleAction();
85
+ if (!(stripos($simpleAction, 'gift_product_')===false)){
86
+ list($g, $p, $giftId) = explode('_',$simpleAction);
87
+ $this->addGiftCart($giftId);
88
+ $giftIds[]=$giftId;
89
+ }
90
+ }
91
+ $this->removeGifts(false,$giftIds);
92
+ }
93
+ }
94
+ }
95
+ }
96
+ }
97
+ public function removeGifts($giftToDelet,$giftsToLet=false) {
98
+
99
+ foreach (Mage::getSingleton('checkout/session')->getQuote()->getAllItems() as $item) {
100
+ if($giftToDelet&&$item->getProductId() == $giftToDelet->getProductId()) {
101
+ Mage::getSingleton('checkout/cart')->removeItem($item->getId())->save();
102
+ break;
103
+ }
104
+ elseif(is_array($giftsToLet)){
105
+ foreach ($this->_giftsCollection as $gift){
106
+ if($item->getProductId() == $gift->getProductId()&&(!in_array( $gift->getId(), $giftsToLet))) {
107
+ Mage::getSingleton('checkout/cart')->removeItem($item->getId())->save();
108
+ }
109
+ }
110
+ }
111
+ }
112
+ }
113
+
114
+ public function getProduct($productId) {
115
+ if ($productId) {
116
+ $product = Mage::getModel('catalog/product')
117
+ ->load($productId);
118
+ if ($product->getId()) {
119
+ return $product;
120
+ }
121
+ }
122
+ return false;
123
+ }
124
+
125
+ }
app/code/community/S3ibusiness/Giftpromo/Model/Status.php ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @category S3ibusiness
4
+ * @package S3ibusiness_Giftpromo
5
+ * @copyright Copyright (c) 2011 S3i Business sarl au. (http://www.s3ibusiness.com)
6
+ * @author Ahmed Mahi <1hmedmahi@gmail.com>
7
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
8
+ */
9
+ class S3ibusiness_Giftpromo_Model_Status extends Varien_Object
10
+ {
11
+ const STATUS_ENABLED = 1;
12
+ const STATUS_DISABLED = 2;
13
+
14
+ static public function getOptionArray()
15
+ {
16
+ return array(
17
+ self::STATUS_ENABLED => Mage::helper('giftpromo')->__('Enabled'),
18
+ self::STATUS_DISABLED => Mage::helper('giftpromo')->__('Disabled')
19
+ );
20
+ }
21
+ }
app/code/community/S3ibusiness/Giftpromo/controllers/Adminhtml/IndexController.php ADDED
@@ -0,0 +1,192 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @category S3ibusiness
4
+ * @package S3ibusiness_Giftpromo
5
+ * @copyright Copyright (c) 2011 S3i Business sarl au. (http://www.s3ibusiness.com)
6
+ * @author Ahmed Mahi <1hmedmahi@gmail.com>
7
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
8
+ */
9
+ class S3ibusiness_Giftpromo_Adminhtml_indexController extends Mage_Adminhtml_Controller_action
10
+ {
11
+
12
+ protected function _initAction() {
13
+ $this->loadLayout()
14
+ // ->_setActiveMenu('giftpromo/items')
15
+ ->_addBreadcrumb(Mage::helper('giftpromo')->__('Gifts Manager'), Mage::helper('giftpromo')->__('Gift Manager'));
16
+
17
+ return $this;
18
+ }
19
+
20
+ public function indexAction() {
21
+ $this->_initAction()
22
+ ->_addContent($this->getLayout()->createBlock('giftpromo/adminhtml_giftpromo'))
23
+ ->renderLayout();
24
+ }
25
+
26
+ public function editAction() {
27
+ $id = $this->getRequest()->getParam('id');
28
+ $model = Mage::getModel('giftpromo/giftpromo')->load($id);
29
+
30
+ if ($model->getId() || $id == 0) {
31
+ $data = Mage::getSingleton('adminhtml/session')->getFormData(true);
32
+ if (!empty($data)) {
33
+ $model->setData($data);
34
+ }
35
+
36
+ Mage::register('giftpromo_data', $model);
37
+
38
+ $this->loadLayout();
39
+ //$this->_setActiveMenu('giftpromo/items');
40
+
41
+ $this->_addBreadcrumb(Mage::helper('giftpromo')->__('Gift Manager'), Mage::helper('giftpromo')->__('Gift Manager'));
42
+ $this->_addBreadcrumb(Mage::helper('giftpromo')->__('Gift News'), Mage::helper('giftpromo')->__('Gift News'));
43
+
44
+ $this->getLayout()->getBlock('head')->setCanLoadExtJs(true);
45
+
46
+ $this->_addContent($this->getLayout()->createBlock('giftpromo/adminhtml_giftpromo_edit'))
47
+ ->_addLeft($this->getLayout()->createBlock('giftpromo/adminhtml_giftpromo_edit_tabs'));
48
+
49
+ $this->renderLayout();
50
+ } else {
51
+ Mage::getSingleton('adminhtml/session')->addError(Mage::helper('giftpromo')->__('Gift does not exist'));
52
+ $this->_redirect('*/*/');
53
+ }
54
+ }
55
+
56
+ public function newAction() {
57
+ $this->_forward('edit');
58
+ }
59
+
60
+ public function saveAction() {
61
+ if ($data = $this->getRequest()->getPost()) {
62
+ $model = Mage::getModel('giftpromo/giftpromo');
63
+ $model->setData($data)
64
+ ->setId($this->getRequest()->getParam('id'));
65
+ $col=$model->getCollection()->addFieldToFilter('product_id',$data['product_id']);
66
+ foreach($col as $g){
67
+ if($g->getId()!=$model->getId()){
68
+ Mage::getSingleton('adminhtml/session')->addError(Mage::helper('giftpromo')->__('Please select another product id'));
69
+ $this->_redirect('*/*/edit', array('id' => $this->getRequest()->getParam('id')));
70
+ return;
71
+ }
72
+ }
73
+ try {
74
+ $model->save();
75
+ Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('giftpromo')->__('Gift was successfully saved'));
76
+ Mage::getSingleton('adminhtml/session')->setFormData(false);
77
+
78
+ if ($this->getRequest()->getParam('back')) {
79
+ $this->_redirect('*/*/edit', array('id' => $model->getId()));
80
+ return;
81
+ }
82
+ $this->_redirect('*/*/');
83
+ return;
84
+ } catch (Exception $e) {
85
+ Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
86
+ Mage::getSingleton('adminhtml/session')->setFormData($data);
87
+ $this->_redirect('*/*/edit', array('id' => $this->getRequest()->getParam('id')));
88
+ return;
89
+ }
90
+ }
91
+ Mage::getSingleton('adminhtml/session')->addError(Mage::helper('giftpromo')->__('Unable to find gift to save'));
92
+ $this->_redirect('*/*/');
93
+ }
94
+
95
+ public function deleteAction() {
96
+ if( $this->getRequest()->getParam('id') > 0 ) {
97
+ try {
98
+ $model = Mage::getModel('giftpromo/giftpromo');
99
+
100
+ $model->setId($this->getRequest()->getParam('id'))
101
+ ->delete();
102
+
103
+ Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('giftpromo')->__('Gift was successfully deleted'));
104
+ $this->_redirect('*/*/');
105
+ } catch (Exception $e) {
106
+ Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
107
+ $this->_redirect('*/*/edit', array('id' => $this->getRequest()->getParam('id')));
108
+ }
109
+ }
110
+ $this->_redirect('*/*/');
111
+ }
112
+
113
+ public function massDeleteAction() {
114
+ $giftpromoIds = $this->getRequest()->getParam('giftpromo');
115
+ if(!is_array($giftpromoIds)) {
116
+ Mage::getSingleton('adminhtml/session')->addError(Mage::helper('giftpromo')->__('Please select gift(s)'));
117
+ } else {
118
+ try {
119
+ foreach ($giftpromoIds as $giftpromoId) {
120
+ $giftpromo = Mage::getModel('giftpromo/giftpromo')->load($giftpromoId);
121
+ $giftpromo->delete();
122
+ }
123
+ Mage::getSingleton('adminhtml/session')->addSuccess(
124
+ Mage::helper('giftpromo')->__(
125
+ 'Total of %d record(s) were successfully deleted', count($giftpromoIds)
126
+ )
127
+ );
128
+ } catch (Exception $e) {
129
+ Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
130
+ }
131
+ }
132
+ $this->_redirect('*/*/index');
133
+ }
134
+
135
+ public function massStatusAction()
136
+ {
137
+ $giftpromoIds = $this->getRequest()->getParam('giftpromo');
138
+ if(!is_array($giftpromoIds)) {
139
+ Mage::getSingleton('adminhtml/session')->addError($this->__('Please select gift(s)'));
140
+ } else {
141
+ try {
142
+ foreach ($giftpromoIds as $giftpromoId) {
143
+ $giftpromo = Mage::getSingleton('giftpromo/giftpromo')
144
+ ->load($giftpromoId)
145
+ ->setStatus($this->getRequest()->getParam('status'))
146
+ ->setIsMassupdate(true)
147
+ ->save();
148
+ }
149
+ $this->_getSession()->addSuccess(
150
+ $this->__('Total of %d record(s) were successfully updated', count($giftpromoIds))
151
+ );
152
+ } catch (Exception $e) {
153
+ $this->_getSession()->addError($e->getMessage());
154
+ }
155
+ }
156
+ $this->_redirect('*/*/index');
157
+ }
158
+
159
+ public function exportCsvAction()
160
+ {
161
+ $fileName = 'giftpromo.csv';
162
+ $content = $this->getLayout()->createBlock('giftpromo/adminhtml_giftpromo_grid')
163
+ ->getCsv();
164
+
165
+ $this->_sendUploadResponse($fileName, $content);
166
+ }
167
+
168
+ public function exportXmlAction()
169
+ {
170
+ $fileName = 'giftpromo.xml';
171
+ $content = $this->getLayout()->createBlock('giftpromo/adminhtml_giftpromo_grid')
172
+ ->getXml();
173
+
174
+ $this->_sendUploadResponse($fileName, $content);
175
+ }
176
+
177
+ protected function _sendUploadResponse($fileName, $content, $contentType='application/octet-stream')
178
+ {
179
+ $response = $this->getResponse();
180
+ $response->setHeader('HTTP/1.1 200 OK','');
181
+ $response->setHeader('Pragma', 'public', true);
182
+ $response->setHeader('Cache-Control', 'must-revalidate, post-check=0, pre-check=0', true);
183
+ $response->setHeader('Content-Disposition', 'attachment; filename='.$fileName);
184
+ $response->setHeader('Last-Modified', date('r'));
185
+ $response->setHeader('Accept-Ranges', 'bytes');
186
+ $response->setHeader('Content-Length', strlen($content));
187
+ $response->setHeader('Content-type', $contentType);
188
+ $response->setBody($content);
189
+ $response->sendResponse();
190
+ die;
191
+ }
192
+ }
app/code/community/S3ibusiness/Giftpromo/etc/adminhtml.xml ADDED
@@ -0,0 +1,59 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <!--
3
+ /**
4
+ * @category S3ibusiness
5
+ * @package S3ibusiness_Giftpromo
6
+ * @copyright Copyright (c) 2011 S3i Business sarl au. (http://www.s3ibusiness.com)
7
+ * @author Ahmed Mahi <1hmedmahi@gmail.com>
8
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
9
+ */
10
+ -->
11
+ <config>
12
+ <menu>
13
+ <promo>
14
+ <children>
15
+ <quote translate="title" module="salesrule">
16
+ <children>
17
+ <giftpromo translate="title" module="giftpromo">
18
+ <title>Manage gifts</title>
19
+ <action>giftpromo/adminhtml_index</action>
20
+ </giftpromo>
21
+ </children>
22
+ </quote>
23
+ </children>
24
+ </promo>
25
+ </menu>
26
+ <acl>
27
+ <resources>
28
+ <admin>
29
+ <children>
30
+ <giftpromo translate="title" module="giftpromo">
31
+ <title>Manage gift</title>
32
+ <sort_order>10</sort_order>
33
+ </giftpromo>
34
+ <system>
35
+ <children>
36
+ <config>
37
+ <children>
38
+ <giftpromo translate="title" module="giftpromo">
39
+ <title>GiftPromo Module</title>
40
+ <sort_order>50</sort_order>
41
+ </giftpromo>
42
+ </children>
43
+ </config>
44
+ </children>
45
+ </system>
46
+ </children>
47
+ </admin>
48
+ </resources>
49
+ </acl>
50
+ <translate>
51
+ <modules>
52
+ <S3ibusiness_Giftpromo>
53
+ <files>
54
+ <default>S3ibusiness_Giftpromo.csv</default>
55
+ </files>
56
+ </S3ibusiness_Giftpromo>
57
+ </modules>
58
+ </translate>
59
+ </config>
app/code/community/S3ibusiness/Giftpromo/etc/config.xml ADDED
@@ -0,0 +1,152 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <!--
3
+ /**
4
+ * @category S3ibusiness
5
+ * @package S3ibusiness_Giftpromo
6
+ * @copyright Copyright (c) 2011 S3i Business sarl au. (http://www.s3ibusiness.com)
7
+ * @author Ahmed Mahi <1hmedmahi@gmail.com>
8
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
9
+ */
10
+ -->
11
+ <config>
12
+ <modules>
13
+ <S3ibusiness_Giftpromo>
14
+ <version>0.1.2</version>
15
+ </S3ibusiness_Giftpromo>
16
+ </modules>
17
+ <admin>
18
+ <routers>
19
+ <giftpromo>
20
+ <use>admin</use>
21
+ <args>
22
+ <module>S3ibusiness_Giftpromo</module>
23
+ <frontName>giftpromo</frontName>
24
+ </args>
25
+ </giftpromo>
26
+ </routers>
27
+ </admin>
28
+ <adminhtml>
29
+ <menu>
30
+ <promo>
31
+ <children>
32
+ <quote translate="title" module="salesrule">
33
+ <children>
34
+ <giftpromo translate="title" module="giftpromo">
35
+ <title>Manage gifts</title>
36
+ <action>giftpromo/adminhtml_index</action>
37
+ </giftpromo>
38
+ </children>
39
+ </quote>
40
+ </children>
41
+ </promo>
42
+ </menu>
43
+ <acl>
44
+ <resources>
45
+ <admin>
46
+ <children>
47
+ <giftpromo translate="title" module="giftpromo">
48
+ <title>Manage gift</title>
49
+ <sort_order>10</sort_order>
50
+ </giftpromo>
51
+ <system>
52
+ <children>
53
+ <config>
54
+ <children>
55
+ <giftpromo translate="title" module="giftpromo">
56
+ <title>GiftPromo Module</title>
57
+ <sort_order>50</sort_order>
58
+ </giftpromo>
59
+ </children>
60
+ </config>
61
+ </children>
62
+ </system>
63
+ </children>
64
+ </admin>
65
+ </resources>
66
+ </acl>
67
+ <translate>
68
+ <modules>
69
+ <S3ibusiness_Giftpromo>
70
+ <files>
71
+ <default>S3ibusiness_Giftpromo.csv</default>
72
+ </files>
73
+ </S3ibusiness_Giftpromo>
74
+ </modules>
75
+ </translate>
76
+ </adminhtml>
77
+ <global>
78
+ <events>
79
+ <core_block_abstract_to_html_before>
80
+ <observers>
81
+ <s3ibusiness_giftpromo_simple_action>
82
+ <type>singleton</type>
83
+ <class>giftpromo/observer</class>
84
+ <method>deleteDiscountTitle</method>
85
+ </s3ibusiness_giftpromo_simple_action>
86
+ </observers>
87
+ </core_block_abstract_to_html_before>
88
+ <controller_action_postdispatch>
89
+ <observers>
90
+ <s3ibusiness_giftpromo_addgift>
91
+ <type>singleton</type>
92
+ <class>giftpromo/observer</class>
93
+ <method>addGifts</method>
94
+ </s3ibusiness_giftpromo_addgift>
95
+ </observers>
96
+ </controller_action_postdispatch>
97
+ <adminhtml_block_salesrule_actions_prepareform>
98
+ <observers>
99
+ <s3ibusiness_giftpromo_simple_action>
100
+ <type>singleton</type>
101
+ <class>giftpromo/observer</class>
102
+ <method>addSimpleAction</method>
103
+ </s3ibusiness_giftpromo_simple_action>
104
+ </observers>
105
+ </adminhtml_block_salesrule_actions_prepareform>
106
+ </events>
107
+ <models>
108
+ <giftpromo>
109
+ <class>S3ibusiness_Giftpromo_Model</class>
110
+ <resourceModel>giftpromo_mysql4</resourceModel>
111
+ </giftpromo>
112
+ <giftpromo_mysql4>
113
+ <class>S3ibusiness_Giftpromo_Model_Mysql4</class>
114
+ <entities>
115
+ <giftpromo>
116
+ <table>giftpromo</table>
117
+ </giftpromo>
118
+ </entities>
119
+ </giftpromo_mysql4>
120
+ </models>
121
+ <resources>
122
+ <giftpromo_setup>
123
+ <setup>
124
+ <module>S3ibusiness_Giftpromo</module>
125
+ </setup>
126
+ <connection>
127
+ <use>core_setup</use>
128
+ </connection>
129
+ </giftpromo_setup>
130
+ <giftpromo_write>
131
+ <connection>
132
+ <use>core_write</use>
133
+ </connection>
134
+ </giftpromo_write>
135
+ <giftpromo_read>
136
+ <connection>
137
+ <use>core_read</use>
138
+ </connection>
139
+ </giftpromo_read>
140
+ </resources>
141
+ <blocks>
142
+ <giftpromo>
143
+ <class>S3ibusiness_Giftpromo_Block</class>
144
+ </giftpromo>
145
+ </blocks>
146
+ <helpers>
147
+ <giftpromo>
148
+ <class>S3ibusiness_Giftpromo_Helper</class>
149
+ </giftpromo>
150
+ </helpers>
151
+ </global>
152
+ </config>
app/code/community/S3ibusiness/Giftpromo/etc/system.xml ADDED
@@ -0,0 +1,44 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <!--
3
+ /**
4
+ * @category S3ibusiness
5
+ * @package S3ibusiness_Giftpromo
6
+ * @copyright Copyright (c) 2011 S3i Business sarl au. (http://www.s3ibusiness.com)
7
+ * @author Ahmed Mahi <1hmedmahi@gmail.com>
8
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
9
+ */
10
+ -->
11
+ <config>
12
+ <sections>
13
+ <giftpromo translate="label" module="giftpromo">
14
+ <label>GiftPromo</label>
15
+ <tab>sales</tab>
16
+ <frontend_type>text</frontend_type>
17
+ <sort_order>900</sort_order>
18
+ <show_in_default>1</show_in_default>
19
+ <show_in_website>1</show_in_website>
20
+ <show_in_store>0</show_in_store>
21
+ <groups>
22
+ <settings translate="label">
23
+ <label>Settings</label>
24
+ <frontend_type>text</frontend_type>
25
+ <sort_order>1</sort_order>
26
+ <show_in_default>1</show_in_default>
27
+ <show_in_website>1</show_in_website>
28
+ <show_in_store>0</show_in_store>
29
+ <fields>
30
+ <enabled translate="label">
31
+ <label>Enabled</label>
32
+ <frontend_type>select</frontend_type>
33
+ <source_model>adminhtml/system_config_source_yesno</source_model>
34
+ <sort_order>1</sort_order>
35
+ <show_in_default>1</show_in_default>
36
+ <show_in_website>1</show_in_website>
37
+ <show_in_store>0</show_in_store>
38
+ </enabled>
39
+ </fields>
40
+ </settings>
41
+ </groups>
42
+ </giftpromo>
43
+ </sections>
44
+ </config>
app/code/community/S3ibusiness/Giftpromo/sql/giftpromo_setup/mysql4-install-0.1.0.php ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ $installer = $this;
4
+
5
+ $installer->startSetup();
6
+
7
+ $installer->run("
8
+
9
+ -- DROP TABLE IF EXISTS {$this->getTable('giftpromo')};
10
+ CREATE TABLE {$this->getTable('giftpromo')} (
11
+ `gift_id` int(11) unsigned NOT NULL auto_increment,
12
+ `product_id` int(11) unsigned NOT NULL default 0,
13
+ `gift_name` varchar(255) NOT NULL default '',
14
+ `status` smallint(6) NOT NULL default '0',
15
+ PRIMARY KEY (`gift_id`)
16
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
17
+
18
+ ");
19
+
20
+ $installer->endSetup();
app/etc/modules/S3ibusiness_Giftpromo.xml ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <modules>
4
+ <S3ibusiness_Giftpromo>
5
+ <active>true</active>
6
+ <codePool>community</codePool>
7
+ </S3ibusiness_Giftpromo>
8
+ </modules>
9
+ </config>
app/locale/en_US/S3ibusiness_Giftpromo.csv ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Gift information,Gift information
2
+ Gift name,Gift name
3
+ Product id,Product id
4
+ Status,Status
5
+ Enabled,Enabled
6
+ Disabled,Disabled
7
+ Save Gift,Save Gift
8
+ Delete Gift,Delete Gift
9
+ Save and Continue Edit,Save and Continue Edit
10
+ Edit Gift '%s',Edit Gift '%s'
11
+ Add Gift,Add Gift
12
+ Action,Action
13
+ Edit,Edit
14
+ Delete,Delete
15
+ Are you sure?,Are you sure?
16
+ Change status,Change status
17
+ Gift Manager,Gift Manager
18
+ Gift : '%s',Gift : '%s'
19
+ Gift News,Gift News
20
+ Gift does not exist,Gift does not exist
21
+ Gift was successfully saved,Gift was successfully saved
22
+ Unable to find gift to save,Unable to find gift to save
23
+ Gift was successfully deleted,Gift was successfully deleted
24
+ Please select gift(s),Please select gift(s)
25
+ Total of %d record(s) were successfully deleted,Total of %d record(s) were successfully deleted
26
+ Please select another product id,Please select another product id
27
+ Manage gifts,Manage gifts
app/locale/fr_FR/S3ibusiness_Giftpromo.csv ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Gift Information,Information du cadeau
2
+ Gift name,Nom du cadeau
3
+ Product id,Id produit
4
+ Status,Statut
5
+ Enabled,Activé
6
+ Disabled,Désactivé
7
+ Save Gift,Sauvegarder le cadeau
8
+ Delete Gift,Supprimer le cadeau
9
+ Save and Continue Edit,Sauvegarder et continuer à éditer
10
+ Edit Gift '%s',Editer le cadeau '%s'
11
+ Add Gift,Ajouter le cadeau
12
+ Action,Actions
13
+ Edit,Editer
14
+ Delete,Supprimer
15
+ Are you sure?,Etes-vous s&ucirc;r de vouloir faire &ccedil;a ?
16
+ Change status,Changer le statut
17
+ Gift Manager,Gestion du cadeau
18
+ Gift : '%s',cadeau : '%s'
19
+ Gift News,nouveau cadeau
20
+ Gift does not exist,le cadeau n'existe pas
21
+ Gift was successfully saved,Le cadeau a bien été sauvegardé
22
+ Unable to find gift to save,Impossible de trouver le cadeau
23
+ Gift was successfully deleted,Le cadeau a bien été supprimé
24
+ Please select gift(s),Merci de sélectionner au moins un cadeau
25
+ Total of %d record(s) were successfully deleted,Au total&#8218; %d cadeau(s) a/ont été supprimés
26
+ Please select another product id,Merci de sélectionner un autre id produit
27
+ Manage gifts,Gestion des cadeaux
package.xml ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <package>
3
+ <name>S3ibusiness_Giftpromo</name>
4
+ <version>0.1.2</version>
5
+ <stability>stable</stability>
6
+ <license uri="http://www.opensource.org/licenses/osl-3.0.php">Open Software License (OSL 3.0)</license>
7
+ <channel>community</channel>
8
+ <extends/>
9
+ <summary>Associate free gift and Shopping Cart Price Rules</summary>
10
+ <description>Associ&#xE9; un produit cadeau a une r&#xE8;gle de prix panier (r&#xE8;gles de cadeaux)
11
+ Possibilit&#xE9; d'ajout&#xE9;s plusieurs r&#xE8;gles de cadeaux
12
+ Possibilit&#xE9; d'ajout&#xE9;s plus d'un produit si r&#xE8;gles est atteints</description>
13
+ <notes>If you have ideas for improvements or find bugs, please send them to Ahmed MAHI at www.s3ibusiness.com, 1hmedmahi@gmail.com</notes>
14
+ <authors><author><name>Ahmed MAHI</name><user>auto-converted</user><email>1hmedmahi@gmail.com</email></author><author><name>Ahmed MAHI</name><user>auto-converted</user><email>1hmedmahi@gmail.com</email></author></authors>
15
+ <date>2011-04-28</date>
16
+ <time>03:08:46</time>
17
+ <contents><target name="magelocale"><dir name="en_US"><file name="S3ibusiness_Giftpromo.csv" hash="8b2227ebf5d4f477df01a7fb9382c7a4"/></dir><dir name="fr_FR"><file name="S3ibusiness_Giftpromo.csv" hash="c63f82685d01f7ec1193891c42d31861"/></dir></target><target name="mageetc"><dir name="modules"><file name="S3ibusiness_Giftpromo.xml" hash="2e67049078771379bd67cb0325100d2b"/></dir></target><target name="magecommunity"><dir name="S3ibusiness"><dir name="Giftpromo"><dir name="Block"><dir name="Adminhtml"><dir name="Giftpromo"><dir name="Edit"><dir name="Tab"><file name="Form.php" hash="355403013e352fad92f2723c867c27d9"/></dir><file name="Form.php" hash="b348b241d992af0c06f0536162c69381"/><file name="Tabs.php" hash="aef8e6202c1973243650fc23ce852c51"/></dir><file name="Edit.php" hash="7b108405543311a7546147fe39d781af"/><file name="Grid.php" hash="b9c38c1132ffb84c9f4168d8f3ae3da0"/></dir><file name="Giftpromo.php" hash="4e8d8c896d7f6fb6461ad8b3531f137d"/></dir></dir><dir name="controllers"><dir name="Adminhtml"><file name="IndexController.php" hash="64a97ab794e4015c8e540ce4eb412501"/></dir></dir><dir name="etc"><file name="adminhtml.xml" hash="ccd1d34fb079580633f4d64287faaeb1"/><file name="config.xml" hash="39bfbdbad7a04c3fc101523552f0af33"/><file name="system.xml" hash="8cb8e63e9487db02eacbd66f6ca45667"/></dir><dir name="Helper"><file name="Data.php" hash="a6ca9646081104d93c77c93bac28d05e"/></dir><dir name="Model"><dir name="Mysql4"><dir name="Giftpromo"><file name="Collection.php" hash="3ad4dae15dbdf93e4f8022f0bc7a3b96"/></dir><file name="Giftpromo.php" hash="3ec4a445cf54e8ccca0d8a66a1c68cf6"/></dir><file name="Giftpromo.php" hash="4c5e2e02a4fb615ab307549474cf4bfa"/><file name="Observer.php" hash="16041dfbc0df4fc10577d450715afbd1"/><file name="Status.php" hash="4ea52a3dee8ef4c17aa3fd737de81c46"/></dir><dir name="sql"><dir name="giftpromo_setup"><file name="mysql4-install-0.1.0.php" hash="8a09c06b43da6c65664c85b1740a2dcb"/></dir></dir></dir></dir></target></contents>
18
+ <compatible/>
19
+ <dependencies/>
20
+ </package>