Version Notes
This module is use for create lucky draw and user can subscribe for lucky draw.
Download this release
Release Info
| Developer | Navneet |
| Extension | SAG_Luckydraw |
| Version | 1.0.0 |
| Comparing to | |
| See all releases | |
Version 1.0.0
- app/code/community/Sag/Luckydraw/Block/Adminhtml/Luckydraw.php +14 -0
- app/code/community/Sag/Luckydraw/Block/Adminhtml/Luckydraw/Edit.php +45 -0
- app/code/community/Sag/Luckydraw/Block/Adminhtml/Luckydraw/Edit/Form.php +19 -0
- app/code/community/Sag/Luckydraw/Block/Adminhtml/Luckydraw/Edit/Tab/Form.php +59 -0
- app/code/community/Sag/Luckydraw/Block/Adminhtml/Luckydraw/Edit/Tabs.php +24 -0
- app/code/community/Sag/Luckydraw/Block/Adminhtml/Luckydraw/Grid.php +114 -0
- app/code/community/Sag/Luckydraw/Block/Adminhtml/Subscriber.php +14 -0
- app/code/community/Sag/Luckydraw/Block/Adminhtml/Subscriber/Grid.php +76 -0
- app/code/community/Sag/Luckydraw/Block/Luckydraw.php +85 -0
- app/code/community/Sag/Luckydraw/Helper/Data.php +7 -0
- app/code/community/Sag/Luckydraw/Model/Luckydraw.php +14 -0
- app/code/community/Sag/Luckydraw/Model/Mysql4/Luckydraw.php +10 -0
- app/code/community/Sag/Luckydraw/Model/Mysql4/Luckydraw/Collection.php +10 -0
- app/code/community/Sag/Luckydraw/Model/Mysql4/Subscriber.php +10 -0
- app/code/community/Sag/Luckydraw/Model/Mysql4/Subscriber/Collection.php +10 -0
- app/code/community/Sag/Luckydraw/Model/Status.php +17 -0
- app/code/community/Sag/Luckydraw/Model/Subscriber.php +14 -0
- app/code/community/Sag/Luckydraw/controllers/Adminhtml/LuckydrawController.php +184 -0
- app/code/community/Sag/Luckydraw/controllers/Adminhtml/SubscriberController.php +69 -0
- app/code/community/Sag/Luckydraw/controllers/IndexController.php +9 -0
- app/code/community/Sag/Luckydraw/controllers/LuckydrawController.php +9 -0
- app/code/community/Sag/Luckydraw/etc/config.xml +128 -0
- app/code/community/Sag/Luckydraw/sql/luckydraw_setup/mysql4-install-0.1.0.php +39 -0
- app/design/adminhtml/default/default/layout/luckydraw.xml +15 -0
- app/design/frontend/base/default/layout/luckydraw.xml +10 -0
- app/design/frontend/base/default/template/luckydraw/luckydraw.phtml +29 -0
- app/etc/modules/Sag_Luckydraw.xml +9 -0
- package.xml +31 -0
app/code/community/Sag/Luckydraw/Block/Adminhtml/Luckydraw.php
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
class Sag_Luckydraw_Block_Adminhtml_Luckydraw extends Mage_Adminhtml_Block_Widget_Grid_Container
|
| 3 |
+
{
|
| 4 |
+
public function __construct()
|
| 5 |
+
{
|
| 6 |
+
$this->_controller = 'adminhtml_luckydraw';
|
| 7 |
+
$this->_blockGroup = 'luckydraw';
|
| 8 |
+
$this->_headerText = Mage::helper('luckydraw')->__('Luckydraw Manager');
|
| 9 |
+
$this->_addButtonLabel = Mage::helper('luckydraw')->__('Add Luckydraw');
|
| 10 |
+
parent::__construct();
|
| 11 |
+
}
|
| 12 |
+
|
| 13 |
+
|
| 14 |
+
}
|
app/code/community/Sag/Luckydraw/Block/Adminhtml/Luckydraw/Edit.php
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
|
| 3 |
+
class Sag_Luckydraw_Block_Adminhtml_Luckydraw_Edit extends Mage_Adminhtml_Block_Widget_Form_Container
|
| 4 |
+
{
|
| 5 |
+
public function __construct()
|
| 6 |
+
{
|
| 7 |
+
parent::__construct();
|
| 8 |
+
|
| 9 |
+
$this->_objectId = 'id';
|
| 10 |
+
$this->_blockGroup = 'luckydraw';
|
| 11 |
+
$this->_controller = 'adminhtml_luckydraw';
|
| 12 |
+
|
| 13 |
+
$this->_updateButton('save', 'label', Mage::helper('luckydraw')->__('Save Luckydraw'));
|
| 14 |
+
$this->_updateButton('delete', 'label', Mage::helper('luckydraw')->__('Delete Luckydraw'));
|
| 15 |
+
|
| 16 |
+
$this->_addButton('saveandcontinue', array(
|
| 17 |
+
'label' => Mage::helper('adminhtml')->__('Save And Continue Edit'),
|
| 18 |
+
'onclick' => 'saveAndContinueEdit()',
|
| 19 |
+
'class' => 'save',
|
| 20 |
+
), -100);
|
| 21 |
+
|
| 22 |
+
$this->_formScripts[] = "
|
| 23 |
+
function toggleEditor() {
|
| 24 |
+
if (tinyMCE.getInstanceById('luckydraw_content') == null) {
|
| 25 |
+
tinyMCE.execCommand('mceAddControl', false, 'luckydraw_content');
|
| 26 |
+
} else {
|
| 27 |
+
tinyMCE.execCommand('mceRemoveControl', false, 'luckydraw_content');
|
| 28 |
+
}
|
| 29 |
+
}
|
| 30 |
+
|
| 31 |
+
function saveAndContinueEdit(){
|
| 32 |
+
editForm.submit($('edit_form').action+'back/edit/');
|
| 33 |
+
}
|
| 34 |
+
";
|
| 35 |
+
}
|
| 36 |
+
|
| 37 |
+
public function getHeaderText()
|
| 38 |
+
{
|
| 39 |
+
if( Mage::registry('luckydraw_data') && Mage::registry('luckydraw_data')->getId() ) {
|
| 40 |
+
return Mage::helper('luckydraw')->__("Edit Luckydraw '%s'", $this->htmlEscape(Mage::registry('luckydraw_data')->getTitle()));
|
| 41 |
+
} else {
|
| 42 |
+
return Mage::helper('luckydraw')->__('Add Luckydraw');
|
| 43 |
+
}
|
| 44 |
+
}
|
| 45 |
+
}
|
app/code/community/Sag/Luckydraw/Block/Adminhtml/Luckydraw/Edit/Form.php
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
|
| 3 |
+
class Sag_Luckydraw_Block_Adminhtml_Luckydraw_Edit_Form extends Mage_Adminhtml_Block_Widget_Form
|
| 4 |
+
{
|
| 5 |
+
protected function _prepareForm()
|
| 6 |
+
{
|
| 7 |
+
$form = new Varien_Data_Form(array(
|
| 8 |
+
'id' => 'edit_form',
|
| 9 |
+
'action' => $this->getUrl('*/*/save', array('id' => $this->getRequest()->getParam('id'))),
|
| 10 |
+
'method' => 'post',
|
| 11 |
+
'enctype' => 'multipart/form-data'
|
| 12 |
+
)
|
| 13 |
+
);
|
| 14 |
+
|
| 15 |
+
$form->setUseContainer(true);
|
| 16 |
+
$this->setForm($form);
|
| 17 |
+
return parent::_prepareForm();
|
| 18 |
+
}
|
| 19 |
+
}
|
app/code/community/Sag/Luckydraw/Block/Adminhtml/Luckydraw/Edit/Tab/Form.php
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
|
| 3 |
+
class Sag_Luckydraw_Block_Adminhtml_Luckydraw_Edit_Tab_Form extends Mage_Adminhtml_Block_Widget_Form
|
| 4 |
+
{
|
| 5 |
+
protected function _prepareForm()
|
| 6 |
+
{
|
| 7 |
+
$form = new Varien_Data_Form();
|
| 8 |
+
$this->setForm($form);
|
| 9 |
+
$fieldset = $form->addFieldset('luckydraw_form', array('legend'=>Mage::helper('luckydraw')->__('Luckydraw Information')));
|
| 10 |
+
|
| 11 |
+
$fieldset->addField('title', 'text', array(
|
| 12 |
+
'label' => Mage::helper('luckydraw')->__('Title'),
|
| 13 |
+
'class' => 'required-entry',
|
| 14 |
+
'required' => true,
|
| 15 |
+
'name' => 'title',
|
| 16 |
+
));
|
| 17 |
+
|
| 18 |
+
|
| 19 |
+
$fieldset->addField('filename', 'image', array(
|
| 20 |
+
'label' => Mage::helper('luckydraw')->__('Image'),
|
| 21 |
+
'required' => false,
|
| 22 |
+
'name' => 'filename',
|
| 23 |
+
));
|
| 24 |
+
|
| 25 |
+
$fieldset->addField('status', 'select', array(
|
| 26 |
+
'label' => Mage::helper('luckydraw')->__('Status'),
|
| 27 |
+
'name' => 'status',
|
| 28 |
+
'values' => array(
|
| 29 |
+
array(
|
| 30 |
+
'value' => 1,
|
| 31 |
+
'label' => Mage::helper('luckydraw')->__('Enabled'),
|
| 32 |
+
),
|
| 33 |
+
|
| 34 |
+
array(
|
| 35 |
+
'value' => 2,
|
| 36 |
+
'label' => Mage::helper('luckydraw')->__('Disabled'),
|
| 37 |
+
),
|
| 38 |
+
),
|
| 39 |
+
));
|
| 40 |
+
|
| 41 |
+
$fieldset->addField('content', 'editor', array(
|
| 42 |
+
'name' => 'content',
|
| 43 |
+
'label' => Mage::helper('luckydraw')->__('Content'),
|
| 44 |
+
'title' => Mage::helper('luckydraw')->__('Content'),
|
| 45 |
+
'style' => 'width:700px; height:200px;',
|
| 46 |
+
'wysiwyg' => false,
|
| 47 |
+
'required' => true,
|
| 48 |
+
));
|
| 49 |
+
|
| 50 |
+
if ( Mage::getSingleton('adminhtml/session')->getLuckydrawData() )
|
| 51 |
+
{
|
| 52 |
+
$form->setValues(Mage::getSingleton('adminhtml/session')->getLuckydrawData());
|
| 53 |
+
Mage::getSingleton('adminhtml/session')->setLuckydrawData(null);
|
| 54 |
+
} elseif ( Mage::registry('luckydraw_data') ) {
|
| 55 |
+
$form->setValues(Mage::registry('luckydraw_data')->getData());
|
| 56 |
+
}
|
| 57 |
+
return parent::_prepareForm();
|
| 58 |
+
}
|
| 59 |
+
}
|
app/code/community/Sag/Luckydraw/Block/Adminhtml/Luckydraw/Edit/Tabs.php
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
|
| 3 |
+
class Sag_Luckydraw_Block_Adminhtml_Luckydraw_Edit_Tabs extends Mage_Adminhtml_Block_Widget_Tabs
|
| 4 |
+
{
|
| 5 |
+
|
| 6 |
+
public function __construct()
|
| 7 |
+
{
|
| 8 |
+
parent::__construct();
|
| 9 |
+
$this->setId('luckydraw_tabs');
|
| 10 |
+
$this->setDestElementId('edit_form');
|
| 11 |
+
$this->setTitle(Mage::helper('luckydraw')->__('Luckydraw Information'));
|
| 12 |
+
}
|
| 13 |
+
|
| 14 |
+
protected function _beforeToHtml()
|
| 15 |
+
{
|
| 16 |
+
$this->addTab('form_section', array(
|
| 17 |
+
'label' => Mage::helper('luckydraw')->__('Luckydraw Information'),
|
| 18 |
+
'title' => Mage::helper('luckydraw')->__('Luckydraw Information'),
|
| 19 |
+
'content' => $this->getLayout()->createBlock('luckydraw/adminhtml_luckydraw_edit_tab_form')->toHtml(),
|
| 20 |
+
));
|
| 21 |
+
|
| 22 |
+
return parent::_beforeToHtml();
|
| 23 |
+
}
|
| 24 |
+
}
|
app/code/community/Sag/Luckydraw/Block/Adminhtml/Luckydraw/Grid.php
ADDED
|
@@ -0,0 +1,114 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
|
| 3 |
+
class Sag_Luckydraw_Block_Adminhtml_Luckydraw_Grid extends Mage_Adminhtml_Block_Widget_Grid
|
| 4 |
+
{
|
| 5 |
+
public function __construct()
|
| 6 |
+
{
|
| 7 |
+
parent::__construct();
|
| 8 |
+
$this->setId('luckydrawGrid');
|
| 9 |
+
$this->setDefaultSort('luckydraw_id');
|
| 10 |
+
$this->setDefaultDir('ASC');
|
| 11 |
+
$this->setSaveParametersInSession(true);
|
| 12 |
+
}
|
| 13 |
+
|
| 14 |
+
protected function _prepareCollection()
|
| 15 |
+
{
|
| 16 |
+
$collection = Mage::getModel('luckydraw/luckydraw')->getCollection();
|
| 17 |
+
$this->setCollection($collection);
|
| 18 |
+
return parent::_prepareCollection();
|
| 19 |
+
}
|
| 20 |
+
|
| 21 |
+
protected function _prepareColumns()
|
| 22 |
+
{
|
| 23 |
+
$this->addColumn('luckydraw_id', array(
|
| 24 |
+
'header' => Mage::helper('luckydraw')->__('ID'),
|
| 25 |
+
'align' =>'right',
|
| 26 |
+
'width' => '50px',
|
| 27 |
+
'index' => 'luckydraw_id',
|
| 28 |
+
));
|
| 29 |
+
|
| 30 |
+
$this->addColumn('title', array(
|
| 31 |
+
'header' => Mage::helper('luckydraw')->__('Title'),
|
| 32 |
+
'align' =>'left',
|
| 33 |
+
'index' => 'title',
|
| 34 |
+
));
|
| 35 |
+
|
| 36 |
+
/*
|
| 37 |
+
$this->addColumn('content', array(
|
| 38 |
+
'header' => Mage::helper('luckydraw')->__('Item Content'),
|
| 39 |
+
'width' => '150px',
|
| 40 |
+
'index' => 'content',
|
| 41 |
+
));
|
| 42 |
+
*/
|
| 43 |
+
|
| 44 |
+
$this->addColumn('status', array(
|
| 45 |
+
'header' => Mage::helper('luckydraw')->__('Status'),
|
| 46 |
+
'align' => 'left',
|
| 47 |
+
'width' => '80px',
|
| 48 |
+
'index' => 'status',
|
| 49 |
+
'type' => 'options',
|
| 50 |
+
'options' => array(
|
| 51 |
+
1 => 'Enabled',
|
| 52 |
+
2 => 'Disabled',
|
| 53 |
+
),
|
| 54 |
+
));
|
| 55 |
+
|
| 56 |
+
$this->addColumn('action',
|
| 57 |
+
array(
|
| 58 |
+
'header' => Mage::helper('luckydraw')->__('Action'),
|
| 59 |
+
'width' => '100',
|
| 60 |
+
'type' => 'action',
|
| 61 |
+
'getter' => 'getId',
|
| 62 |
+
'actions' => array(
|
| 63 |
+
array(
|
| 64 |
+
'caption' => Mage::helper('luckydraw')->__('Edit'),
|
| 65 |
+
'url' => array('base'=> '*/*/edit'),
|
| 66 |
+
'field' => 'id'
|
| 67 |
+
)
|
| 68 |
+
),
|
| 69 |
+
'filter' => false,
|
| 70 |
+
'sortable' => false,
|
| 71 |
+
'index' => 'stores',
|
| 72 |
+
'is_system' => true,
|
| 73 |
+
));
|
| 74 |
+
|
| 75 |
+
|
| 76 |
+
return parent::_prepareColumns();
|
| 77 |
+
}
|
| 78 |
+
|
| 79 |
+
protected function _prepareMassaction()
|
| 80 |
+
{
|
| 81 |
+
$this->setMassactionIdField('luckydraw_id');
|
| 82 |
+
$this->getMassactionBlock()->setFormFieldName('luckydraw');
|
| 83 |
+
|
| 84 |
+
$this->getMassactionBlock()->addItem('delete', array(
|
| 85 |
+
'label' => Mage::helper('luckydraw')->__('Delete'),
|
| 86 |
+
'url' => $this->getUrl('*/*/massDelete'),
|
| 87 |
+
'confirm' => Mage::helper('luckydraw')->__('Are you sure?')
|
| 88 |
+
));
|
| 89 |
+
|
| 90 |
+
$statuses = Mage::getSingleton('luckydraw/status')->getOptionArray();
|
| 91 |
+
|
| 92 |
+
array_unshift($statuses, array('label'=>'', 'value'=>''));
|
| 93 |
+
$this->getMassactionBlock()->addItem('status', array(
|
| 94 |
+
'label'=> Mage::helper('luckydraw')->__('Change status'),
|
| 95 |
+
'url' => $this->getUrl('*/*/massStatus', array('_current'=>true)),
|
| 96 |
+
'additional' => array(
|
| 97 |
+
'visibility' => array(
|
| 98 |
+
'name' => 'status',
|
| 99 |
+
'type' => 'select',
|
| 100 |
+
'class' => 'required-entry',
|
| 101 |
+
'label' => Mage::helper('luckydraw')->__('Status'),
|
| 102 |
+
'values' => $statuses
|
| 103 |
+
)
|
| 104 |
+
)
|
| 105 |
+
));
|
| 106 |
+
return $this;
|
| 107 |
+
}
|
| 108 |
+
|
| 109 |
+
public function getRowUrl($row)
|
| 110 |
+
{
|
| 111 |
+
return $this->getUrl('*/*/edit', array('id' => $row->getId()));
|
| 112 |
+
}
|
| 113 |
+
|
| 114 |
+
}
|
app/code/community/Sag/Luckydraw/Block/Adminhtml/Subscriber.php
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
class Sag_Luckydraw_Block_Adminhtml_Subscriber extends Mage_Adminhtml_Block_Widget_Grid_Container
|
| 3 |
+
{
|
| 4 |
+
public function __construct()
|
| 5 |
+
{
|
| 6 |
+
$this->_controller = 'adminhtml_subscriber';
|
| 7 |
+
$this->_blockGroup = 'luckydraw';
|
| 8 |
+
$this->_headerText = Mage::helper('luckydraw')->__('Subscriber Manager');
|
| 9 |
+
parent::__construct();
|
| 10 |
+
$this->_removeButton('add');
|
| 11 |
+
}
|
| 12 |
+
|
| 13 |
+
|
| 14 |
+
}
|
app/code/community/Sag/Luckydraw/Block/Adminhtml/Subscriber/Grid.php
ADDED
|
@@ -0,0 +1,76 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
|
| 3 |
+
class Sag_Luckydraw_Block_Adminhtml_Subscriber_Grid extends Mage_Adminhtml_Block_Widget_Grid
|
| 4 |
+
{
|
| 5 |
+
public function __construct()
|
| 6 |
+
{
|
| 7 |
+
parent::__construct();
|
| 8 |
+
$this->setId('subscriberGrid');
|
| 9 |
+
$this->setDefaultSort('subscriber_id');
|
| 10 |
+
$this->setDefaultDir('ASC');
|
| 11 |
+
$this->setSaveParametersInSession(true);
|
| 12 |
+
}
|
| 13 |
+
|
| 14 |
+
protected function _prepareCollection()
|
| 15 |
+
{
|
| 16 |
+
$collection = Mage::getModel('luckydraw/subscriber')->getCollection();
|
| 17 |
+
$this->setCollection($collection);
|
| 18 |
+
return parent::_prepareCollection();
|
| 19 |
+
}
|
| 20 |
+
|
| 21 |
+
protected function _prepareColumns()
|
| 22 |
+
{
|
| 23 |
+
$this->addColumn('subscriber_id', array(
|
| 24 |
+
'header' => Mage::helper('luckydraw')->__('ID'),
|
| 25 |
+
'align' =>'right',
|
| 26 |
+
'width' => '50px',
|
| 27 |
+
'index' => 'subscriber_id',
|
| 28 |
+
));
|
| 29 |
+
|
| 30 |
+
$this->addColumn('subscriber_email', array(
|
| 31 |
+
'header' => Mage::helper('luckydraw')->__('Email'),
|
| 32 |
+
'align' =>'left',
|
| 33 |
+
'index' => 'subscriber_email',
|
| 34 |
+
));
|
| 35 |
+
|
| 36 |
+
|
| 37 |
+
|
| 38 |
+
|
| 39 |
+
///////////////////////////////////Luckydraw////////////////////////////////////
|
| 40 |
+
$_draw = Mage::getModel('luckydraw/luckydraw')->getCollection();
|
| 41 |
+
foreach($_draw as $item)
|
| 42 |
+
{
|
| 43 |
+
if($item->getParent == NULL){
|
| 44 |
+
$_lukydrawIds[$item->getLuckydrawId()] = $item->getTitle();
|
| 45 |
+
}
|
| 46 |
+
}
|
| 47 |
+
$this->addColumn('luckydraw_id', array(
|
| 48 |
+
'header' => Mage::helper('luckydraw')->__('Luckydraw'),
|
| 49 |
+
'align' => 'left',
|
| 50 |
+
'width' => '300px',
|
| 51 |
+
'index' => 'luckydraw_id',
|
| 52 |
+
'type' => 'options',
|
| 53 |
+
'options' => $_lukydrawIds,
|
| 54 |
+
));
|
| 55 |
+
///////////////////////////////////Luckydraw////////////////////////////////////
|
| 56 |
+
|
| 57 |
+
|
| 58 |
+
|
| 59 |
+
return parent::_prepareColumns();
|
| 60 |
+
}
|
| 61 |
+
|
| 62 |
+
protected function _prepareMassaction()
|
| 63 |
+
{
|
| 64 |
+
$this->setMassactionIdField('subscriber_id');
|
| 65 |
+
$this->getMassactionBlock()->setFormFieldName('subscriber');
|
| 66 |
+
|
| 67 |
+
$this->getMassactionBlock()->addItem('delete', array(
|
| 68 |
+
'label' => Mage::helper('luckydraw')->__('Delete'),
|
| 69 |
+
'url' => $this->getUrl('*/*/massDelete'),
|
| 70 |
+
'confirm' => Mage::helper('luckydraw')->__('Are you sure?')
|
| 71 |
+
));
|
| 72 |
+
|
| 73 |
+
|
| 74 |
+
return $this;
|
| 75 |
+
}
|
| 76 |
+
}
|
app/code/community/Sag/Luckydraw/Block/Luckydraw.php
ADDED
|
@@ -0,0 +1,85 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
class Sag_Luckydraw_Block_Luckydraw extends Mage_Core_Block_Template
|
| 3 |
+
{
|
| 4 |
+
public function _prepareLayout()
|
| 5 |
+
{
|
| 6 |
+
return parent::_prepareLayout();
|
| 7 |
+
}
|
| 8 |
+
|
| 9 |
+
public function getLuckydraw()
|
| 10 |
+
{
|
| 11 |
+
if (!$this->hasData('luckydraw')) {
|
| 12 |
+
$this->setData('luckydraw', Mage::getModel('luckydraw/luckydraw')->getCollection()->addFilter('status', '1'));
|
| 13 |
+
}
|
| 14 |
+
return $this->getData('luckydraw');
|
| 15 |
+
}
|
| 16 |
+
|
| 17 |
+
|
| 18 |
+
public function getFormActionUrl()
|
| 19 |
+
{
|
| 20 |
+
return $this->getUrl('luckydraw', array('_secure' => true));
|
| 21 |
+
}
|
| 22 |
+
|
| 23 |
+
|
| 24 |
+
public function postAction()
|
| 25 |
+
{
|
| 26 |
+
//echo $_POST['email'].'<br>';
|
| 27 |
+
//echo $_POST['luckydraw_id'];
|
| 28 |
+
|
| 29 |
+
$write = Mage::getSingleton('core/resource')->getConnection('core_write');
|
| 30 |
+
|
| 31 |
+
// now $write is an instance of Zend_Db_Adapter_Abstract
|
| 32 |
+
$readresult=$write->query("SELECT *
|
| 33 |
+
FROM subscriber
|
| 34 |
+
WHERE
|
| 35 |
+
subscriber_email='".$_POST['email']."' and luckydraw_id='".$_POST['luckydraw_id']."'");
|
| 36 |
+
|
| 37 |
+
|
| 38 |
+
$row = $readresult->fetch();
|
| 39 |
+
if($row['subscriber_id']!=''){
|
| 40 |
+
Mage::getSingleton('core/session')->addSuccess('This Email Id is already exists.');
|
| 41 |
+
}else{
|
| 42 |
+
$write->query("INSERT INTO subscriber (subscriber_email, luckydraw_id, created_time) VALUES ('".$_POST['email']."', '".$_POST['luckydraw_id']."', now())");
|
| 43 |
+
Mage::getSingleton('core/session')->addSuccess('Email Id is saved.');
|
| 44 |
+
}
|
| 45 |
+
header('location:../luckydraw');exit;
|
| 46 |
+
}
|
| 47 |
+
|
| 48 |
+
|
| 49 |
+
|
| 50 |
+
|
| 51 |
+
/**
|
| 52 |
+
* Resize Image proportionally and return the resized image url
|
| 53 |
+
*
|
| 54 |
+
* @param string $imageName name of the image file
|
| 55 |
+
* @param integer|null $width resize width
|
| 56 |
+
* @param integer|null $height resize height
|
| 57 |
+
* @param string|null $imagePath directory path of the image present inside media directory
|
| 58 |
+
* @return string full url path of the image
|
| 59 |
+
*/
|
| 60 |
+
public function resizeImage($imageName, $width=NULL, $height=NULL, $imagePath=NULL)
|
| 61 |
+
{
|
| 62 |
+
$imagePath = str_replace("/", DS, $imagePath);
|
| 63 |
+
$imagePathFull = Mage::getBaseDir('media') . DS . $imagePath . DS . $imageName;
|
| 64 |
+
|
| 65 |
+
if($width == NULL && $height == NULL) {
|
| 66 |
+
$width = 100;
|
| 67 |
+
$height = 100;
|
| 68 |
+
}
|
| 69 |
+
$resizePath = $width . 'x' . $height;
|
| 70 |
+
$resizePathFull = Mage::getBaseDir('media') . DS . $imagePath . DS . $resizePath . DS . $imageName;
|
| 71 |
+
|
| 72 |
+
if (file_exists($imagePathFull) && !file_exists($resizePathFull)) {
|
| 73 |
+
$imageObj = new Varien_Image($imagePathFull);
|
| 74 |
+
$imageObj->constrainOnly(TRUE);
|
| 75 |
+
$imageObj->keepAspectRatio(TRUE);
|
| 76 |
+
$imageObj->resize($width,$height);
|
| 77 |
+
$imageObj->save($resizePathFull);
|
| 78 |
+
}
|
| 79 |
+
|
| 80 |
+
$imagePath=str_replace(DS, "/", $imagePath);
|
| 81 |
+
$img = Mage::getBaseUrl("media") . $imagePath . "/" . $resizePath . "/" . $imageName;
|
| 82 |
+
return str_replace(DS, "/", $img);
|
| 83 |
+
}
|
| 84 |
+
|
| 85 |
+
}
|
app/code/community/Sag/Luckydraw/Helper/Data.php
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
|
| 3 |
+
class Sag_Luckydraw_Helper_Data extends Mage_Core_Helper_Abstract
|
| 4 |
+
{
|
| 5 |
+
|
| 6 |
+
}
|
| 7 |
+
?>
|
app/code/community/Sag/Luckydraw/Model/Luckydraw.php
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
|
| 3 |
+
class Sag_Luckydraw_Model_Luckydraw extends Mage_Core_Model_Abstract
|
| 4 |
+
{
|
| 5 |
+
public function _construct()
|
| 6 |
+
{
|
| 7 |
+
parent::_construct();
|
| 8 |
+
$this->_init('luckydraw/luckydraw');
|
| 9 |
+
}
|
| 10 |
+
|
| 11 |
+
public function getCollection() {
|
| 12 |
+
return Mage::getResourceModel('luckydraw/luckydraw_collection');
|
| 13 |
+
}
|
| 14 |
+
}
|
app/code/community/Sag/Luckydraw/Model/Mysql4/Luckydraw.php
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
|
| 3 |
+
class Sag_Luckydraw_Model_Mysql4_Luckydraw extends Mage_Core_Model_Mysql4_Abstract
|
| 4 |
+
{
|
| 5 |
+
public function _construct()
|
| 6 |
+
{
|
| 7 |
+
// Note that the gallery_id refers to the key field in your database table.
|
| 8 |
+
$this->_init('luckydraw/luckydraw', 'luckydraw_id');
|
| 9 |
+
}
|
| 10 |
+
}
|
app/code/community/Sag/Luckydraw/Model/Mysql4/Luckydraw/Collection.php
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
|
| 3 |
+
class Sag_Luckydraw_Model_Mysql4_Luckydraw_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract
|
| 4 |
+
{
|
| 5 |
+
public function _construct()
|
| 6 |
+
{
|
| 7 |
+
parent::_construct();
|
| 8 |
+
$this->_init('luckydraw/luckydraw');
|
| 9 |
+
}
|
| 10 |
+
}
|
app/code/community/Sag/Luckydraw/Model/Mysql4/Subscriber.php
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
|
| 3 |
+
class Sag_Luckydraw_Model_Mysql4_Subscriber extends Mage_Core_Model_Mysql4_Abstract
|
| 4 |
+
{
|
| 5 |
+
public function _construct()
|
| 6 |
+
{
|
| 7 |
+
// Note that the subscriber_id refers to the key field in your database table.
|
| 8 |
+
$this->_init('luckydraw/subscriber', 'subscriber_id');
|
| 9 |
+
}
|
| 10 |
+
}
|
app/code/community/Sag/Luckydraw/Model/Mysql4/Subscriber/Collection.php
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
|
| 3 |
+
class Sag_Luckydraw_Model_Mysql4_Subscriber_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract
|
| 4 |
+
{
|
| 5 |
+
public function _construct()
|
| 6 |
+
{
|
| 7 |
+
parent::_construct();
|
| 8 |
+
$this->_init('luckydraw/subscriber');
|
| 9 |
+
}
|
| 10 |
+
}
|
app/code/community/Sag/Luckydraw/Model/Status.php
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
|
| 3 |
+
class Sag_Luckydraw_Model_Status extends Varien_Object
|
| 4 |
+
{
|
| 5 |
+
const STATUS_ENABLED = 1;
|
| 6 |
+
const STATUS_DISABLED = 2;
|
| 7 |
+
|
| 8 |
+
static public function getOptionArray()
|
| 9 |
+
{
|
| 10 |
+
return array(
|
| 11 |
+
self::STATUS_ENABLED => Mage::helper('luckydraw')->__('Enabled'),
|
| 12 |
+
self::STATUS_DISABLED => Mage::helper('luckydraw')->__('Disabled')
|
| 13 |
+
);
|
| 14 |
+
}
|
| 15 |
+
}
|
| 16 |
+
|
| 17 |
+
?>
|
app/code/community/Sag/Luckydraw/Model/Subscriber.php
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
|
| 3 |
+
class Sag_Luckydraw_Model_Subscriber extends Mage_Core_Model_Abstract
|
| 4 |
+
{
|
| 5 |
+
public function _construct()
|
| 6 |
+
{
|
| 7 |
+
parent::_construct();
|
| 8 |
+
$this->_init('luckydraw/subscriber');
|
| 9 |
+
}
|
| 10 |
+
|
| 11 |
+
public function getCollection() {
|
| 12 |
+
return Mage::getResourceModel('luckydraw/subscriber_collection');
|
| 13 |
+
}
|
| 14 |
+
}
|
app/code/community/Sag/Luckydraw/controllers/Adminhtml/LuckydrawController.php
ADDED
|
@@ -0,0 +1,184 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
|
| 3 |
+
class Sag_Luckydraw_Adminhtml_LuckydrawController extends Mage_Adminhtml_Controller_action
|
| 4 |
+
{
|
| 5 |
+
|
| 6 |
+
protected function _initAction() {
|
| 7 |
+
$this->loadLayout()
|
| 8 |
+
->_setActiveMenu('luckydraw/Luckydraws')
|
| 9 |
+
->_addBreadcrumb(Mage::helper('adminhtml')->__('Luckydraw Manager'), Mage::helper('adminhtml')->__('Luckydraw Manager'));
|
| 10 |
+
|
| 11 |
+
return $this;
|
| 12 |
+
}
|
| 13 |
+
|
| 14 |
+
public function indexAction() {
|
| 15 |
+
$this->_initAction()
|
| 16 |
+
->renderLayout();
|
| 17 |
+
}
|
| 18 |
+
|
| 19 |
+
public function editAction() {
|
| 20 |
+
$id = $this->getRequest()->getParam('id');
|
| 21 |
+
$model = Mage::getModel('luckydraw/luckydraw')->load($id);
|
| 22 |
+
|
| 23 |
+
if ($model->getId() || $id == 0) {
|
| 24 |
+
$data = Mage::getSingleton('adminhtml/session')->getFormData(true);
|
| 25 |
+
if (!empty($data)) {
|
| 26 |
+
$model->setData($data);
|
| 27 |
+
}
|
| 28 |
+
|
| 29 |
+
Mage::register('luckydraw_data', $model);
|
| 30 |
+
|
| 31 |
+
$this->loadLayout();
|
| 32 |
+
$this->_setActiveMenu('luckydraw/luckydraws');
|
| 33 |
+
|
| 34 |
+
$this->_addBreadcrumb(Mage::helper('adminhtml')->__('Luckydraw Manager'), Mage::helper('adminhtml')->__('Luckydraw Manager'));
|
| 35 |
+
|
| 36 |
+
$this->getLayout()->getBlock('head')->setCanLoadExtJs(true);
|
| 37 |
+
|
| 38 |
+
$this->_addContent($this->getLayout()->createBlock('luckydraw/adminhtml_luckydraw_edit'))
|
| 39 |
+
->_addLeft($this->getLayout()->createBlock('luckydraw/adminhtml_luckydraw_edit_tabs'));
|
| 40 |
+
|
| 41 |
+
$this->renderLayout();
|
| 42 |
+
} else {
|
| 43 |
+
Mage::getSingleton('adminhtml/session')->addError(Mage::helper('luckydraw')->__('Luckydraw does not exist'));
|
| 44 |
+
$this->_redirect('*/*/');
|
| 45 |
+
}
|
| 46 |
+
}
|
| 47 |
+
|
| 48 |
+
public function newAction() {
|
| 49 |
+
$this->_forward('edit');
|
| 50 |
+
}
|
| 51 |
+
|
| 52 |
+
public function saveAction() {
|
| 53 |
+
if ($data = $this->getRequest()->getPost()) {
|
| 54 |
+
|
| 55 |
+
if(isset($_FILES['filename']['name']) && $_FILES['filename']['name'] != '') {
|
| 56 |
+
try {
|
| 57 |
+
/* Starting upload */
|
| 58 |
+
$uploader = new Varien_File_Uploader('filename');
|
| 59 |
+
|
| 60 |
+
// Any extention would work
|
| 61 |
+
$uploader->setAllowedExtensions(array('jpg','jpeg','gif','png'));
|
| 62 |
+
$uploader->setAllowRenameFiles(false);
|
| 63 |
+
|
| 64 |
+
// Set the file upload mode
|
| 65 |
+
// false -> get the file directly in the specified folder
|
| 66 |
+
// true -> get the file in the product like folders
|
| 67 |
+
// (file.jpg will go in something like /media/f/i/file.jpg)
|
| 68 |
+
$uploader->setFilesDispersion(false);
|
| 69 |
+
|
| 70 |
+
// We set media as the upload dir
|
| 71 |
+
$path = Mage::getBaseDir('media') . DS . 'luckydraw' . DS. 'luckydraw' . DS;
|
| 72 |
+
$uploader->save($path, str_replace(' ', '_',$_FILES['filename']['name']) );
|
| 73 |
+
|
| 74 |
+
} catch (Exception $e) {
|
| 75 |
+
|
| 76 |
+
}
|
| 77 |
+
|
| 78 |
+
//this way the name is saved in DB
|
| 79 |
+
$data['filename'] = 'luckydraw' . DS. 'luckydraw' . DS. str_replace(' ', '_',$_FILES['filename']['name']);
|
| 80 |
+
}else {
|
| 81 |
+
unset($data['filename']); // Unset filename part when image upload field is empty
|
| 82 |
+
}
|
| 83 |
+
|
| 84 |
+
|
| 85 |
+
|
| 86 |
+
$model = Mage::getModel('luckydraw/luckydraw');
|
| 87 |
+
$model->setData($data)
|
| 88 |
+
->setId($this->getRequest()->getParam('id'));
|
| 89 |
+
|
| 90 |
+
try {
|
| 91 |
+
if ($model->getCreatedTime == NULL || $model->getUpdateTime() == NULL) {
|
| 92 |
+
$model->setCreatedTime(now())
|
| 93 |
+
->setUpdateTime(now());
|
| 94 |
+
} else {
|
| 95 |
+
$model->setUpdateTime(now());
|
| 96 |
+
}
|
| 97 |
+
|
| 98 |
+
$model->save();
|
| 99 |
+
Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('luckydraw')->__('Luckydraw was successfully saved'));
|
| 100 |
+
Mage::getSingleton('adminhtml/session')->setFormData(false);
|
| 101 |
+
|
| 102 |
+
if ($this->getRequest()->getParam('back')) {
|
| 103 |
+
$this->_redirect('*/*/edit', array('id' => $model->getId()));
|
| 104 |
+
return;
|
| 105 |
+
}
|
| 106 |
+
$this->_redirect('*/*/');
|
| 107 |
+
return;
|
| 108 |
+
} catch (Exception $e) {
|
| 109 |
+
Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
|
| 110 |
+
Mage::getSingleton('adminhtml/session')->setFormData($data);
|
| 111 |
+
$this->_redirect('*/*/edit', array('id' => $this->getRequest()->getParam('id')));
|
| 112 |
+
return;
|
| 113 |
+
}
|
| 114 |
+
}
|
| 115 |
+
Mage::getSingleton('adminhtml/session')->addError(Mage::helper('luckydraw')->__('Unable to find Luckydraw to save'));
|
| 116 |
+
$this->_redirect('*/*/');
|
| 117 |
+
}
|
| 118 |
+
|
| 119 |
+
public function deleteAction() {
|
| 120 |
+
if( $this->getRequest()->getParam('id') > 0 ) {
|
| 121 |
+
try {
|
| 122 |
+
$model = Mage::getModel('luckydraw/luckydraw');
|
| 123 |
+
|
| 124 |
+
$model->setId($this->getRequest()->getParam('id'))
|
| 125 |
+
->delete();
|
| 126 |
+
|
| 127 |
+
Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('adminhtml')->__('Luckydraw was successfully deleted'));
|
| 128 |
+
$this->_redirect('*/*/');
|
| 129 |
+
} catch (Exception $e) {
|
| 130 |
+
Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
|
| 131 |
+
$this->_redirect('*/*/edit', array('id' => $this->getRequest()->getParam('id')));
|
| 132 |
+
}
|
| 133 |
+
}
|
| 134 |
+
$this->_redirect('*/*/');
|
| 135 |
+
}
|
| 136 |
+
|
| 137 |
+
public function massDeleteAction() {
|
| 138 |
+
$luckydrawIds = $this->getRequest()->getParam('luckydraw');
|
| 139 |
+
if(!is_array($luckydrawIds)) {
|
| 140 |
+
Mage::getSingleton('adminhtml/session')->addError(Mage::helper('adminhtml')->__('Please select Luckydraw(s)'));
|
| 141 |
+
} else {
|
| 142 |
+
try {
|
| 143 |
+
foreach ($luckydrawIds as $luckydrawId) {
|
| 144 |
+
$luckydraw = Mage::getModel('luckydraw/luckydraw')->load($luckydrawId);
|
| 145 |
+
$luckydraw->delete();
|
| 146 |
+
}
|
| 147 |
+
Mage::getSingleton('adminhtml/session')->addSuccess(
|
| 148 |
+
Mage::helper('adminhtml')->__(
|
| 149 |
+
'Total of %d record(s) were successfully deleted', count($luckydrawIds)
|
| 150 |
+
)
|
| 151 |
+
);
|
| 152 |
+
} catch (Exception $e) {
|
| 153 |
+
Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
|
| 154 |
+
}
|
| 155 |
+
}
|
| 156 |
+
$this->_redirect('*/*/index');
|
| 157 |
+
}
|
| 158 |
+
|
| 159 |
+
public function massStatusAction()
|
| 160 |
+
{
|
| 161 |
+
$luckydrawIds = $this->getRequest()->getParam('luckydraw');
|
| 162 |
+
if(!is_array($luckydrawIds)) {
|
| 163 |
+
Mage::getSingleton('adminhtml/session')->addError($this->__('Please select Luckydraw(s)'));
|
| 164 |
+
} else {
|
| 165 |
+
try {
|
| 166 |
+
foreach ($luckydrawIds as $luckydrawId) {
|
| 167 |
+
$luckydraw = Mage::getSingleton('luckydraw/luckydraw')
|
| 168 |
+
->load($luckydrawId)
|
| 169 |
+
->setStatus($this->getRequest()->getParam('status'))
|
| 170 |
+
->setIsMassupdate(true)
|
| 171 |
+
->save();
|
| 172 |
+
}
|
| 173 |
+
$this->_getSession()->addSuccess(
|
| 174 |
+
$this->__('Total of %d record(s) were successfully updated', count($luckydrawIds))
|
| 175 |
+
);
|
| 176 |
+
} catch (Exception $e) {
|
| 177 |
+
$this->_getSession()->addError($e->getMessage());
|
| 178 |
+
}
|
| 179 |
+
}
|
| 180 |
+
$this->_redirect('*/*/index');
|
| 181 |
+
}
|
| 182 |
+
|
| 183 |
+
|
| 184 |
+
}
|
app/code/community/Sag/Luckydraw/controllers/Adminhtml/SubscriberController.php
ADDED
|
@@ -0,0 +1,69 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
|
| 3 |
+
class Sag_Luckydraw_Adminhtml_SubscriberController extends Mage_Adminhtml_Controller_action
|
| 4 |
+
{
|
| 5 |
+
|
| 6 |
+
protected function _initAction() {
|
| 7 |
+
$this->loadLayout()
|
| 8 |
+
->_setActiveMenu('luckydraw/subscribers')
|
| 9 |
+
->_addBreadcrumb(Mage::helper('adminhtml')->__('Subscriber Manager'), Mage::helper('adminhtml')->__('Subscriber Manager'));
|
| 10 |
+
|
| 11 |
+
return $this;
|
| 12 |
+
}
|
| 13 |
+
|
| 14 |
+
public function indexAction() {
|
| 15 |
+
$this->_initAction()
|
| 16 |
+
->renderLayout();
|
| 17 |
+
}
|
| 18 |
+
|
| 19 |
+
|
| 20 |
+
|
| 21 |
+
|
| 22 |
+
public function newAction() {
|
| 23 |
+
$this->_forward('edit');
|
| 24 |
+
}
|
| 25 |
+
|
| 26 |
+
|
| 27 |
+
public function deleteAction() {
|
| 28 |
+
if( $this->getRequest()->getParam('id') > 0 ) {
|
| 29 |
+
try {
|
| 30 |
+
$model = Mage::getModel('luckydraw/subscriber');
|
| 31 |
+
|
| 32 |
+
$model->setId($this->getRequest()->getParam('id'))
|
| 33 |
+
->delete();
|
| 34 |
+
|
| 35 |
+
Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('adminhtml')->__('Subscriber was successfully deleted'));
|
| 36 |
+
$this->_redirect('*/*/');
|
| 37 |
+
} catch (Exception $e) {
|
| 38 |
+
Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
|
| 39 |
+
$this->_redirect('*/*/edit', array('id' => $this->getRequest()->getParam('id')));
|
| 40 |
+
}
|
| 41 |
+
}
|
| 42 |
+
$this->_redirect('*/*/');
|
| 43 |
+
}
|
| 44 |
+
|
| 45 |
+
public function massDeleteAction() {
|
| 46 |
+
$subscriberIds = $this->getRequest()->getParam('subscriber');
|
| 47 |
+
if(!is_array($subscriberIds)) {
|
| 48 |
+
Mage::getSingleton('adminhtml/session')->addError(Mage::helper('adminhtml')->__('Please select Subscriber(s)'));
|
| 49 |
+
} else {
|
| 50 |
+
try {
|
| 51 |
+
foreach ($subscriberIds as $subscriberId) {
|
| 52 |
+
$subscriber = Mage::getModel('luckydraw/subscriber')->load($subscriberId);
|
| 53 |
+
$subscriber->delete();
|
| 54 |
+
}
|
| 55 |
+
Mage::getSingleton('adminhtml/session')->addSuccess(
|
| 56 |
+
Mage::helper('adminhtml')->__(
|
| 57 |
+
'Total of %d record(s) were successfully deleted', count($subscriberIds)
|
| 58 |
+
)
|
| 59 |
+
);
|
| 60 |
+
} catch (Exception $e) {
|
| 61 |
+
Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
|
| 62 |
+
}
|
| 63 |
+
}
|
| 64 |
+
$this->_redirect('*/*/index');
|
| 65 |
+
}
|
| 66 |
+
|
| 67 |
+
|
| 68 |
+
|
| 69 |
+
}
|
app/code/community/Sag/Luckydraw/controllers/IndexController.php
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
class Sag_Luckydraw_IndexController extends Mage_Core_Controller_Front_Action
|
| 3 |
+
{
|
| 4 |
+
public function indexAction()
|
| 5 |
+
{
|
| 6 |
+
$this->loadLayout();
|
| 7 |
+
$this->renderLayout();
|
| 8 |
+
}
|
| 9 |
+
}
|
app/code/community/Sag/Luckydraw/controllers/LuckydrawController.php
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
class Sag_Luckydraw_LuckydrawController extends Mage_Core_Controller_Front_Action
|
| 3 |
+
{
|
| 4 |
+
public function indexAction()
|
| 5 |
+
{
|
| 6 |
+
$this->loadLayout();
|
| 7 |
+
$this->renderLayout();
|
| 8 |
+
}
|
| 9 |
+
}
|
app/code/community/Sag/Luckydraw/etc/config.xml
ADDED
|
@@ -0,0 +1,128 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?xml version="1.0"?>
|
| 2 |
+
<config>
|
| 3 |
+
<modules>
|
| 4 |
+
<Sag_Luckydraw>
|
| 5 |
+
<version>1.0.0</version>
|
| 6 |
+
</Sag_Luckydraw>
|
| 7 |
+
</modules>
|
| 8 |
+
<frontend>
|
| 9 |
+
<routers>
|
| 10 |
+
<luckydraw>
|
| 11 |
+
<use>standard</use>
|
| 12 |
+
<args>
|
| 13 |
+
<module>Sag_Luckydraw</module>
|
| 14 |
+
<frontName>luckydraw</frontName>
|
| 15 |
+
</args>
|
| 16 |
+
</luckydraw>
|
| 17 |
+
</routers>
|
| 18 |
+
<layout>
|
| 19 |
+
<updates>
|
| 20 |
+
<luckydraw>
|
| 21 |
+
<file>luckydraw.xml</file>
|
| 22 |
+
</luckydraw>
|
| 23 |
+
</updates>
|
| 24 |
+
</layout>
|
| 25 |
+
</frontend>
|
| 26 |
+
<admin>
|
| 27 |
+
<routers>
|
| 28 |
+
<luckydraw>
|
| 29 |
+
<use>admin</use>
|
| 30 |
+
<args>
|
| 31 |
+
<module>Sag_Luckydraw</module>
|
| 32 |
+
<frontName>luckydraw</frontName>
|
| 33 |
+
</args>
|
| 34 |
+
</luckydraw>
|
| 35 |
+
</routers>
|
| 36 |
+
</admin>
|
| 37 |
+
<adminhtml>
|
| 38 |
+
<menu>
|
| 39 |
+
<luckydraw module="luckydraw">
|
| 40 |
+
<title>Luckydraw</title>
|
| 41 |
+
<sort_order>171</sort_order>
|
| 42 |
+
<children>
|
| 43 |
+
<luckydraw module="luckydraw">
|
| 44 |
+
<title>Manage Luckydraw</title>
|
| 45 |
+
<sort_order>10</sort_order>
|
| 46 |
+
<action>luckydraw/adminhtml_luckydraw</action>
|
| 47 |
+
</luckydraw>
|
| 48 |
+
<subscribers module="luckydraw">
|
| 49 |
+
<title>Manage Subscribers</title>
|
| 50 |
+
<sort_order>11</sort_order>
|
| 51 |
+
<action>luckydraw/adminhtml_subscriber</action>
|
| 52 |
+
</subscribers>
|
| 53 |
+
</children>
|
| 54 |
+
</luckydraw>
|
| 55 |
+
</menu>
|
| 56 |
+
<acl>
|
| 57 |
+
<resources>
|
| 58 |
+
<all>
|
| 59 |
+
<title>Allow Everything</title>
|
| 60 |
+
</all>
|
| 61 |
+
<admin>
|
| 62 |
+
<children>
|
| 63 |
+
<Sag_Luckydraw>
|
| 64 |
+
<title>Luckydraw Module</title>
|
| 65 |
+
<sort_order>10</sort_order>
|
| 66 |
+
</Sag_Luckydraw>
|
| 67 |
+
</children>
|
| 68 |
+
</admin>
|
| 69 |
+
</resources>
|
| 70 |
+
</acl>
|
| 71 |
+
<layout>
|
| 72 |
+
<updates>
|
| 73 |
+
<luckydraw>
|
| 74 |
+
<file>luckydraw.xml</file>
|
| 75 |
+
</luckydraw>
|
| 76 |
+
</updates>
|
| 77 |
+
</layout>
|
| 78 |
+
</adminhtml>
|
| 79 |
+
<global>
|
| 80 |
+
<models>
|
| 81 |
+
<luckydraw>
|
| 82 |
+
<class>Sag_Luckydraw_Model</class>
|
| 83 |
+
<resourceModel>luckydraw_mysql4</resourceModel>
|
| 84 |
+
</luckydraw>
|
| 85 |
+
<luckydraw_mysql4>
|
| 86 |
+
<class>Sag_Luckydraw_Model_Mysql4</class>
|
| 87 |
+
<entities>
|
| 88 |
+
<luckydraw>
|
| 89 |
+
<table>luckydraw</table>
|
| 90 |
+
</luckydraw>
|
| 91 |
+
<subscriber>
|
| 92 |
+
<table>subscriber</table>
|
| 93 |
+
</subscriber>
|
| 94 |
+
</entities>
|
| 95 |
+
</luckydraw_mysql4>
|
| 96 |
+
</models>
|
| 97 |
+
<resources>
|
| 98 |
+
<luckydraw_setup>
|
| 99 |
+
<setup>
|
| 100 |
+
<module>Sag_Luckydraw</module>
|
| 101 |
+
</setup>
|
| 102 |
+
<connection>
|
| 103 |
+
<use>core_setup</use>
|
| 104 |
+
</connection>
|
| 105 |
+
</luckydraw_setup>
|
| 106 |
+
<luckydraw_write>
|
| 107 |
+
<connection>
|
| 108 |
+
<use>core_write</use>
|
| 109 |
+
</connection>
|
| 110 |
+
</luckydraw_write>
|
| 111 |
+
<luckydraw_read>
|
| 112 |
+
<connection>
|
| 113 |
+
<use>core_read</use>
|
| 114 |
+
</connection>
|
| 115 |
+
</luckydraw_read>
|
| 116 |
+
</resources>
|
| 117 |
+
<blocks>
|
| 118 |
+
<luckydraw>
|
| 119 |
+
<class>Sag_Luckydraw_Block</class>
|
| 120 |
+
</luckydraw>
|
| 121 |
+
</blocks>
|
| 122 |
+
<helpers>
|
| 123 |
+
<luckydraw>
|
| 124 |
+
<class>Sag_Luckydraw_Helper</class>
|
| 125 |
+
</luckydraw>
|
| 126 |
+
</helpers>
|
| 127 |
+
</global>
|
| 128 |
+
</config>
|
app/code/community/Sag/Luckydraw/sql/luckydraw_setup/mysql4-install-0.1.0.php
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
|
| 3 |
+
$installer = $this;
|
| 4 |
+
|
| 5 |
+
$installer->startSetup();
|
| 6 |
+
|
| 7 |
+
$installer->run("
|
| 8 |
+
|
| 9 |
+
-- DROP TABLE IF EXISTS {$this->getTable('luckydraw')};
|
| 10 |
+
CREATE TABLE {$this->getTable('luckydraw')} (
|
| 11 |
+
`luckydraw_id` int(11) unsigned NOT NULL auto_increment,
|
| 12 |
+
`title` varchar(255) NOT NULL default '',
|
| 13 |
+
`filename` varchar(255) NOT NULL default '',
|
| 14 |
+
`content` text NOT NULL default '',
|
| 15 |
+
`status` smallint(6) NOT NULL default '0',
|
| 16 |
+
`created_time` datetime NULL,
|
| 17 |
+
`update_time` datetime NULL,
|
| 18 |
+
PRIMARY KEY (`luckydraw_id`)
|
| 19 |
+
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
| 20 |
+
|
| 21 |
+
");
|
| 22 |
+
|
| 23 |
+
|
| 24 |
+
|
| 25 |
+
$installer->run("
|
| 26 |
+
|
| 27 |
+
-- DROP TABLE IF EXISTS {$this->getTable('subscriber')};
|
| 28 |
+
CREATE TABLE {$this->getTable('subscriber')} (
|
| 29 |
+
`subscriber_id` int(11) NOT NULL AUTO_INCREMENT,
|
| 30 |
+
`subscriber_email` varchar(256) NOT NULL,
|
| 31 |
+
`luckydraw_id` int(11) NOT NULL,
|
| 32 |
+
`created_time` datetime NOT NULL,
|
| 33 |
+
PRIMARY KEY (`subscriber_id`)
|
| 34 |
+
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
| 35 |
+
|
| 36 |
+
");
|
| 37 |
+
|
| 38 |
+
|
| 39 |
+
$installer->endSetup();
|
app/design/adminhtml/default/default/layout/luckydraw.xml
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?xml version="1.0"?>
|
| 2 |
+
<layout version="0.1.0">
|
| 3 |
+
<luckydraw_adminhtml_luckydraw_index>
|
| 4 |
+
<reference name="content">
|
| 5 |
+
<block type="luckydraw/adminhtml_luckydraw" name="luckydraw" />
|
| 6 |
+
</reference>
|
| 7 |
+
</luckydraw_adminhtml_luckydraw_index>
|
| 8 |
+
|
| 9 |
+
<luckydraw_adminhtml_subscriber_index>
|
| 10 |
+
<reference name="content">
|
| 11 |
+
<block type="luckydraw/adminhtml_subscriber" name="subscriber" />
|
| 12 |
+
</reference>
|
| 13 |
+
</luckydraw_adminhtml_subscriber_index>
|
| 14 |
+
|
| 15 |
+
</layout>
|
app/design/frontend/base/default/layout/luckydraw.xml
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?xml version="1.0"?>
|
| 2 |
+
<layout version="0.1.0">
|
| 3 |
+
<default>
|
| 4 |
+
</default>
|
| 5 |
+
<luckydraw_index_index>
|
| 6 |
+
<reference name="content">
|
| 7 |
+
<block type="luckydraw/luckydraw" name="luckydraw" template="luckydraw/luckydraw.phtml" />
|
| 8 |
+
</reference>
|
| 9 |
+
</luckydraw_index_index>
|
| 10 |
+
</layout>
|
app/design/frontend/base/default/template/luckydraw/luckydraw.phtml
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
if($_POST['submit_luckydraw']=='Submit'){ $this->postAction(); }
|
| 3 |
+
?>
|
| 4 |
+
|
| 5 |
+
<div class="page-title">
|
| 6 |
+
<h1><?php echo $this->__('Luckydraw') ?></h1>
|
| 7 |
+
</div>
|
| 8 |
+
|
| 9 |
+
<?php $cnt = count($this->getLuckydraw()); ?>
|
| 10 |
+
<?php if($cnt > 0 ): ?>
|
| 11 |
+
<div id="luckydraw_con">
|
| 12 |
+
<?php foreach ($this->getLuckydraw() as $item): ?>
|
| 13 |
+
<img src="<?php echo $this->resizeImage($item->getFilename(), 208, 230, ''); ?>" alt="<?php echo $item->getTitle(); ?>" />
|
| 14 |
+
<?php echo $item->getTitle(); ?>
|
| 15 |
+
<form action="<?php echo $this->getFormActionUrl(); ?>" method="post" id="luckydraw-validate-detail">
|
| 16 |
+
<input type="hidden" name="luckydraw_id" id="luckydraw_id" value="<?php echo $item->getLuckydrawId(); ?>" />
|
| 17 |
+
<input type="text" name="email" id="email" class="input-text required-entry validate-email" />
|
| 18 |
+
<input type="submit" name="submit_luckydraw" value="Submit" />
|
| 19 |
+
</form>
|
| 20 |
+
<script type="text/javascript">
|
| 21 |
+
//<![CDATA[
|
| 22 |
+
var luckydrawFormDetail = new VarienForm('luckydraw-validate-detail');
|
| 23 |
+
//]]>
|
| 24 |
+
</script>
|
| 25 |
+
<?php endforeach; ?>
|
| 26 |
+
</div>
|
| 27 |
+
<?php else: ?>
|
| 28 |
+
<div>There is no Luckydraw here</div>
|
| 29 |
+
<?php endif; ?>
|
app/etc/modules/Sag_Luckydraw.xml
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?xml version="1.0"?>
|
| 2 |
+
<config>
|
| 3 |
+
<modules>
|
| 4 |
+
<Sag_Luckydraw>
|
| 5 |
+
<active>true</active>
|
| 6 |
+
<codePool>community</codePool>
|
| 7 |
+
</Sag_Luckydraw>
|
| 8 |
+
</modules>
|
| 9 |
+
</config>
|
package.xml
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?xml version="1.0"?>
|
| 2 |
+
<package>
|
| 3 |
+
<name>SAG_Luckydraw</name>
|
| 4 |
+
<version>1.0.0</version>
|
| 5 |
+
<stability>stable</stability>
|
| 6 |
+
<license>OSL v3.0</license>
|
| 7 |
+
<channel>community</channel>
|
| 8 |
+
<extends/>
|
| 9 |
+
<summary>This module is use for create lucky draw and user can subscribe for lucky draw.</summary>
|
| 10 |
+
<description>This module is use for create lucky draw and user can subscribe for lucky draw.
|
| 11 |
+

|
| 12 |
+
<h3>Features:</h3>
|
| 13 |
+
<ul>
|
| 14 |
+
<li>Create lucky draw and user can subscribe to lucky draw. </li>
|
| 15 |
+
<li>Lucky draw itself is very flexible and easily customizable</li>
|
| 16 |
+
<li> Easy to install</li>
|
| 17 |
+
</ul>
|
| 18 |
+

|
| 19 |
+
<h3>Steps:</h3>
|
| 20 |
+
<ul>
|
| 21 |
+
<li> Install module , Clear cache, check admin menu bar , Go to “<b>Luckydraw</b> “ ,here manage luckydraws and manage subscribers .</li>
|
| 22 |
+
<li>Front end: View Luclydraws list by add ”<b>/luckydraw</b>” in url example: www.test.com/luckydraw</li>
|
| 23 |
+
</ul></description>
|
| 24 |
+
<notes>This module is use for create lucky draw and user can subscribe for lucky draw.</notes>
|
| 25 |
+
<authors><author><name>Navneet</name><user>navneetkoshik</user><email>navneet.kshk@gmail.com</email></author></authors>
|
| 26 |
+
<date>2013-10-17</date>
|
| 27 |
+
<time>07:25:53</time>
|
| 28 |
+
<contents><target name="magecommunity"><dir name="Sag"><dir name="Luckydraw"><dir name="Block"><dir name="Adminhtml"><dir name="Luckydraw"><dir name="Edit"><file name="Form.php" hash="7cf724837b41f40a5431160b756666c3"/><dir name="Tab"><file name="Form.php" hash="597c2706a6eeaabdd918d532c69893cf"/></dir><file name="Tabs.php" hash="f6e525ca9f5812b4e188189e7f793ff9"/></dir><file name="Edit.php" hash="41dcd8b594b83a1254bb36165e3c85f3"/><file name="Grid.php" hash="1db756eddcfa48b7979c6ebcc7d80738"/></dir><file name="Luckydraw.php" hash="68d1ed2b2b702407ee6e224660e7cf97"/><dir name="Subscriber"><file name="Grid.php" hash="4ab4a898443a9c9e5dd4148c28c36fd6"/></dir><file name="Subscriber.php" hash="fbb870b4823efc331d3622c233c7a157"/></dir><file name="Luckydraw.php" hash="589f6a9e7357498c75c93109e2a8a76b"/></dir><dir name="Helper"><file name="Data.php" hash="a9da0f4812b69d4416dacf85578b7fba"/></dir><dir name="Model"><file name="Luckydraw.php" hash="b66d0990e76bf5ca2d95b67edcf95fc1"/><dir name="Mysql4"><dir name="Luckydraw"><file name="Collection.php" hash="ae138162dd5748122fce7d3f7450ce8e"/></dir><file name="Luckydraw.php" hash="951f327c5cdf27421d37bc2c66c8718b"/><dir name="Subscriber"><file name="Collection.php" hash="5238b26c62893e7c1414e6b8a14f57e1"/></dir><file name="Subscriber.php" hash="2b7a419b400230fe69a32e7e30829585"/></dir><file name="Status.php" hash="b3c32201a769c861674b2e7b5ba1777e"/><file name="Subscriber.php" hash="5af81625ac8bc0ac447e427ae2162a8c"/></dir><dir name="controllers"><dir name="Adminhtml"><file name="LuckydrawController.php" hash="2548af50c04651b69e3f7e494696146f"/><file name="SubscriberController.php" hash="91a5cf783c6b8ce197bfeda06845e8ce"/></dir><file name="IndexController.php" hash="f15e78c8e22902fffaae473c0e95ffba"/><file name="LuckydrawController.php" hash="0d5e46f0b8217ca8b3dbd99970798b07"/></dir><dir name="etc"><file name="config.xml" hash="1333053dc70499842b22168eb89e85ca"/></dir><dir name="sql"><dir name="luckydraw_setup"><file name="mysql4-install-0.1.0.php" hash="6a4a599b8989676bf3b11812597c2305"/></dir></dir></dir></dir></target><target name="magedesign"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="layout"><file name="luckydraw.xml" hash="24092b71030c27ab044af2b44289259e"/></dir></dir></dir></dir><dir name="frontend"><dir name="base"><dir name="default"><dir name="layout"><file name="luckydraw.xml" hash="a0a3f85faad0b4670962ba5f0069a371"/></dir><dir name="template"><dir name="luckydraw"><file name="luckydraw.phtml" hash="8987dc92ae2df0550c60c332764990d9"/></dir></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Sag_Luckydraw.xml" hash="269afe33f1b74870977e3e58ef089fbf"/></dir></target></contents>
|
| 29 |
+
<compatible/>
|
| 30 |
+
<dependencies><required><php><min>5.2.0</min><max>6.0.0</max></php></required></dependencies>
|
| 31 |
+
</package>
|
