estimateddeliverydate - Version 0.1.0

Version Notes

Please test thoroughly on a non-live platform before using in a production environment.

Download this release

Release Info

Developer Un.titled
Extension estimateddeliverydate
Version 0.1.0
Comparing to
See all releases


Version 0.1.0

Files changed (26) hide show
  1. app/code/community/Undottitled/Estimateddeliverydate/Block/Adminhtml/Deliveries.php +23 -0
  2. app/code/community/Undottitled/Estimateddeliverydate/Block/Adminhtml/Deliveries/Edit.php +46 -0
  3. app/code/community/Undottitled/Estimateddeliverydate/Block/Adminhtml/Deliveries/Edit/Form.php +28 -0
  4. app/code/community/Undottitled/Estimateddeliverydate/Block/Adminhtml/Deliveries/Edit/Tab/Form.php +63 -0
  5. app/code/community/Undottitled/Estimateddeliverydate/Block/Adminhtml/Deliveries/Edit/Tab/Products.php +257 -0
  6. app/code/community/Undottitled/Estimateddeliverydate/Block/Adminhtml/Deliveries/Edit/Tabs.php +41 -0
  7. app/code/community/Undottitled/Estimateddeliverydate/Block/Adminhtml/Deliveries/Grid.php +75 -0
  8. app/code/community/Undottitled/Estimateddeliverydate/Block/Display.php +17 -0
  9. app/code/community/Undottitled/Estimateddeliverydate/Helper/Data.php +14 -0
  10. app/code/community/Undottitled/Estimateddeliverydate/Model/Deliveries.php +61 -0
  11. app/code/community/Undottitled/Estimateddeliverydate/Model/Mysql4/Deliveries.php +4 -0
  12. app/code/community/Undottitled/Estimateddeliverydate/Model/Mysql4/Deliveries/Collection.php +5 -0
  13. app/code/community/Undottitled/Estimateddeliverydate/Model/Resource/Deliveries.php +27 -0
  14. app/code/community/Undottitled/Estimateddeliverydate/Model/Resource/Deliveries/Collection.php +13 -0
  15. app/code/community/Undottitled/Estimateddeliverydate/controllers/Adminhtml/DeliveriesController.php +138 -0
  16. app/code/community/Undottitled/Estimateddeliverydate/controllers/IndexController.php +30 -0
  17. app/code/community/Undottitled/Estimateddeliverydate/etc/adminhtml.xml +34 -0
  18. app/code/community/Undottitled/Estimateddeliverydate/etc/config.xml +109 -0
  19. app/code/community/Undottitled/Estimateddeliverydate/etc/system.xml +56 -0
  20. app/code/community/Undottitled/Estimateddeliverydate/sql/estimateddeliverydate_setup/install-0.1.0.php +56 -0
  21. app/design/frontend/base/default/layout/estimateddeliverydate.xml +20 -0
  22. app/design/frontend/base/default/template/estimateddeliverydate/catalog/product/view/estimateddeliverydate.phtml +11 -0
  23. app/design/frontend/base/default/template/estimateddeliverydate/catalog/product/view/estimateddeliverydate_simple.phtml +16 -0
  24. app/etc/modules/Undottitled_Estimateddeliverydate.xml +29 -0
  25. js/undottitled/estimateddeliverydate/estimateddeliverydate.js +50 -0
  26. package.xml +20 -0
app/code/community/Undottitled/Estimateddeliverydate/Block/Adminhtml/Deliveries.php ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Undottitled_Estimateddeliverydate_Block_Adminhtml_Deliveries extends Mage_Adminhtml_Block_Widget_Grid_Container
4
+ {
5
+ protected $_addButtonLabel = 'Add New Delivery';
6
+
7
+ public function __construct()
8
+ {
9
+ parent::__construct();
10
+ $this->_controller = 'adminhtml_deliveries';
11
+ $this->_blockGroup = 'estimateddeliverydate';
12
+ $this->_headerText = Mage::helper('estimateddeliverydate')->__('Product Delivery Management');
13
+ }
14
+
15
+
16
+ protected function _prepareLayout()
17
+ {
18
+ $this->setChild( 'grid',
19
+ $this->getLayout()->createBlock( $this->_blockGroup.'/' . $this->_controller . '_grid',
20
+ $this->_controller . '.grid')->setSaveParametersInSession(true) );
21
+ return parent::_prepareLayout();
22
+ }
23
+ }
app/code/community/Undottitled/Estimateddeliverydate/Block/Adminhtml/Deliveries/Edit.php ADDED
@@ -0,0 +1,46 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Undottitled_Estimateddeliverydate_Block_Adminhtml_Deliveries_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 = 'estimateddeliverydate';
11
+ $this->_controller = 'adminhtml_deliveries';
12
+ $this->_mode = 'edit';
13
+
14
+ $this->_addButton('save_and_continue', array(
15
+ 'label' => Mage::helper('adminhtml')->__('Save And Continue Edit'),
16
+ 'onclick' => 'saveAndContinueEdit()',
17
+ 'class' => 'save',
18
+ ), -100);
19
+ $this->_updateButton('save', 'label', Mage::helper('estimateddeliverydate')->__('Save Delivery'));
20
+
21
+ $this->_formScripts[] = "
22
+ function toggleEditor() {
23
+ if (tinyMCE.getInstanceById('form_content') == null) {
24
+ tinyMCE.execCommand('mceAddControl', false, 'edit_form');
25
+ } else {
26
+ tinyMCE.execCommand('mceRemoveControl', false, 'edit_form');
27
+ }
28
+ }
29
+
30
+ function saveAndContinueEdit(){
31
+ editForm.submit($('edit_form').action+'back/edit/');
32
+ }
33
+ ";
34
+ }
35
+
36
+ public function getHeaderText()
37
+ {
38
+ if (Mage::registry('deliveries_data') && Mage::registry('deliveries_data')->getId())
39
+ {
40
+ return Mage::helper('estimateddeliverydate')->__('Edit Delivery ', $this->htmlEscape(Mage::registry('deliveries_data')->getName()));
41
+ } else {
42
+ return Mage::helper('estimateddeliverydate')->__('New Delivery');
43
+ }
44
+ }
45
+
46
+ }
app/code/community/Undottitled/Estimateddeliverydate/Block/Adminhtml/Deliveries/Edit/Form.php ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Undottitled_Estimateddeliverydate_Block_Adminhtml_Deliveries_Edit_Form extends Mage_Adminhtml_Block_Widget_Form
4
+ {
5
+ protected function _prepareForm()
6
+ {
7
+
8
+ $form = new Varien_Data_Form(array(
9
+ 'id' => 'edit_form',
10
+ 'action' => str_replace("adminhtml_deliveries/","deliveries/",$this->getData('action')),
11
+ 'method' => 'post',
12
+ 'enctype' => 'multipart/form-data'
13
+ ));
14
+
15
+ $retailer = Mage::registry('deliveries_data');
16
+ if ($retailer && $retailer->getId()) {
17
+ $form->addField('entity_id', 'hidden', array(
18
+ 'name' => 'id',
19
+ ));
20
+ $form->setValues($retailer->getData());
21
+ }
22
+
23
+ $form->setUseContainer(true);
24
+ $this->setForm($form);
25
+ return parent::_prepareForm();
26
+
27
+ }
28
+ }
app/code/community/Undottitled/Estimateddeliverydate/Block/Adminhtml/Deliveries/Edit/Tab/Form.php ADDED
@@ -0,0 +1,63 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Undottitled_Estimateddeliverydate_Block_Adminhtml_Deliveries_Edit_Tab_Form extends Mage_Adminhtml_Block_Widget_Form
4
+ {
5
+ public function __construct()
6
+ {
7
+ parent::__construct();
8
+ }
9
+
10
+ public function initForm()
11
+ {
12
+ $form = new Varien_Data_Form();
13
+ $this->setForm($form);
14
+ $fieldset = $form->addFieldset('deliveries_form', array('legend'=>Mage::helper('estimateddeliverydate')->__('General Information')));
15
+
16
+ $fieldset->addField('id', 'hidden', array(
17
+ 'name' => 'id'
18
+ ));
19
+
20
+ $fieldset->addField('qty', 'text', array(
21
+ 'label' => Mage::helper('estimateddeliverydate')->__('Quantity Due'),
22
+ 'class' => 'required-entry',
23
+ 'required' => true,
24
+ 'name' => 'qty',
25
+ ));
26
+
27
+ $fieldset->addField('date', 'date', array(
28
+ 'name' => 'date',
29
+ 'class' => 'required-entry',
30
+ 'label' => $this->__('Due date'),
31
+ 'title' => $this->__('Due date'),
32
+ 'time' => true,
33
+ 'required' => true,
34
+ 'image' => $this->getSkinUrl('images/grid-cal.gif'),
35
+ 'input_format' => Varien_Date::DATETIME_INTERNAL_FORMAT,
36
+ 'format' => Mage::app()->getLocale()->getDateTimeFormat(Mage_Core_Model_Locale::FORMAT_TYPE_SHORT),
37
+ ));
38
+
39
+
40
+ $fieldset->addField('status', 'select', array(
41
+ 'label' => Mage::helper('estimateddeliverydate')->__('Delivery Status'),
42
+ 'class' => 'required_entry',
43
+ 'required' => true,
44
+ 'name' => 'status',
45
+ 'values' => array(
46
+ array(
47
+ 'value' => 0,
48
+ 'label' => Mage::helper('estimateddeliverydate')->__('Pending'),
49
+ ),
50
+
51
+ array(
52
+ 'value' => 1,
53
+ 'label' => Mage::helper('estimateddeliverydate')->__('Delivered'),
54
+ )
55
+ ),
56
+ ));
57
+
58
+ if (Mage::registry('deliveries_data')) {
59
+ $form->setValues(Mage::registry('deliveries_data')->getData());
60
+ }
61
+ return parent::_prepareForm();
62
+ }
63
+ }
app/code/community/Undottitled/Estimateddeliverydate/Block/Adminhtml/Deliveries/Edit/Tab/Products.php ADDED
@@ -0,0 +1,257 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Undottitled_Estimateddeliverydate_Block_Adminhtml_Deliveries_Edit_Tab_Products extends Mage_Adminhtml_Block_Widget_Grid
4
+ {
5
+ public function __construct()
6
+ {
7
+ parent::__construct();
8
+ $this->setId('estimateddeliverydate_products');
9
+ $this->setSaveParametersInSession(true);
10
+ $this->setDefaultSort('entity_id');
11
+ $this->setUseAjax(true);
12
+ if ($this->getRequest()->getParam('id')) {
13
+ $this->setDefaultFilter(array('in_products'=>1));
14
+ }
15
+ }
16
+
17
+ public function getCategory()
18
+ {
19
+ //return Mage::registry('category');
20
+ }
21
+
22
+ protected function _addColumnFilterToCollection($column)
23
+ {
24
+ // Set custom filter for in category flag
25
+ if ($column->getId() == 'in_category') {
26
+ $productIds = $this->_getSelectedProducts();
27
+ if (empty($productIds)) {
28
+ $productIds = 0;
29
+ }
30
+ if ($column->getFilter()->getValue()) {
31
+ $this->getCollection()->addFieldToFilter('entity_id', array('in'=>$productIds));
32
+ }
33
+ elseif(!empty($productIds)) {
34
+ $this->getCollection()->addFieldToFilter('entity_id', array('nin'=>$productIds));
35
+ }
36
+ }
37
+ else {
38
+ parent::_addColumnFilterToCollection($column);
39
+ }
40
+ return $this;
41
+ }
42
+
43
+ protected function _prepareCollection()
44
+ {
45
+ $store = $this->_getStore();
46
+ $collection = Mage::getModel('catalog/product')->getCollection()
47
+ ->addAttributeToSelect('sku')
48
+ ->addAttributeToSelect('name')
49
+ ->addAttributeToSelect('attribute_set_id')
50
+ ->addAttributeToSelect('type_id');
51
+
52
+ if (Mage::helper('catalog')->isModuleEnabled('Mage_CatalogInventory')) {
53
+ $collection->joinField('qty',
54
+ 'cataloginventory/stock_item',
55
+ 'qty',
56
+ 'product_id=entity_id',
57
+ '{{table}}.stock_id=1',
58
+ 'left');
59
+ }
60
+ if ($store->getId()) {
61
+ //$collection->setStoreId($store->getId());
62
+ $adminStore = Mage_Core_Model_App::ADMIN_STORE_ID;
63
+ $collection->addStoreFilter($store);
64
+ $collection->joinAttribute(
65
+ 'name',
66
+ 'catalog_product/name',
67
+ 'entity_id',
68
+ null,
69
+ 'inner',
70
+ $adminStore
71
+ );
72
+ $collection->joinAttribute(
73
+ 'custom_name',
74
+ 'catalog_product/name',
75
+ 'entity_id',
76
+ null,
77
+ 'inner',
78
+ $store->getId()
79
+ );
80
+ $collection->joinAttribute(
81
+ 'status',
82
+ 'catalog_product/status',
83
+ 'entity_id',
84
+ null,
85
+ 'inner',
86
+ $store->getId()
87
+ );
88
+ $collection->joinAttribute(
89
+ 'visibility',
90
+ 'catalog_product/visibility',
91
+ 'entity_id',
92
+ null,
93
+ 'inner',
94
+ $store->getId()
95
+ );
96
+ $collection->joinAttribute(
97
+ 'price',
98
+ 'catalog_product/price',
99
+ 'entity_id',
100
+ null,
101
+ 'left',
102
+ $store->getId()
103
+ );
104
+ }
105
+ else {
106
+ $collection->addAttributeToSelect('price');
107
+ $collection->joinAttribute('status', 'catalog_product/status', 'entity_id', null, 'inner');
108
+ $collection->joinAttribute('visibility', 'catalog_product/visibility', 'entity_id', null, 'inner');
109
+ }
110
+ $this->setCollection($collection);
111
+
112
+ $productIds = $this->_getSelectedProducts();
113
+ if (empty($productIds)) {
114
+ $productIds = 0;
115
+ } else {
116
+ // Makes grid only show currently selected product
117
+ //$this->getCollection()->addFieldToFilter('entity_id', array('in'=>$productIds));
118
+ }
119
+
120
+ return parent::_prepareCollection();
121
+ }
122
+
123
+ protected function _prepareColumns()
124
+ {
125
+
126
+ $store = $this->_getStore();
127
+
128
+ $this->addColumn('in_products', array(
129
+ 'header_css_class' => 'a-center',
130
+ 'header' => Mage::helper('sales')->__('Selected'),
131
+ 'type' => 'radio',
132
+ 'width' => '20px',
133
+ 'html_name' => 'in_products[]',
134
+ 'values' => array($this->_getSelectedProducts()),
135
+ 'align' => 'center',
136
+ 'renderer' => new Mage_Adminhtml_Block_Widget_Grid_Column_Renderer_Radio(),
137
+ 'index' => 'entity_id'
138
+ ));
139
+
140
+ $this->addColumn('entity_id',
141
+ array(
142
+ 'header'=> Mage::helper('catalog')->__('Product ID'),
143
+ 'width' => '50px',
144
+ 'type' => 'number',
145
+ 'index' => 'entity_id',
146
+ ));
147
+ $this->addColumn('name',
148
+ array(
149
+ 'header'=> Mage::helper('catalog')->__('Name'),
150
+ 'index' => 'name',
151
+ ));
152
+
153
+ if ($store->getId()) {
154
+ $this->addColumn('custom_name',
155
+ array(
156
+ 'header'=> Mage::helper('catalog')->__('Name in %s', $store->getName()),
157
+ 'index' => 'custom_name',
158
+ ));
159
+ }
160
+
161
+ $this->addColumn('type',
162
+ array(
163
+ 'header'=> Mage::helper('catalog')->__('Type'),
164
+ 'width' => '150px',
165
+ 'index' => 'type_id',
166
+ 'type' => 'options',
167
+ 'options' => Mage::getSingleton('catalog/product_type')->getOptionArray(),
168
+ ));
169
+
170
+ $sets = Mage::getResourceModel('eav/entity_attribute_set_collection')
171
+ ->setEntityTypeFilter(Mage::getModel('catalog/product')->getResource()->getTypeId())
172
+ ->load()
173
+ ->toOptionHash();
174
+
175
+ $this->addColumn('set_name',
176
+ array(
177
+ 'header'=> Mage::helper('catalog')->__('Attrib. Set Name'),
178
+ 'width' => '100px',
179
+ 'index' => 'attribute_set_id',
180
+ 'type' => 'options',
181
+ 'options' => $sets,
182
+ ));
183
+
184
+ $this->addColumn('price',
185
+ array(
186
+ 'header'=> Mage::helper('catalog')->__('Price'),
187
+ 'type' => 'price',
188
+ 'currency_code' => $store->getBaseCurrency()->getCode(),
189
+ 'index' => 'price',
190
+ ));
191
+
192
+ if (Mage::helper('catalog')->isModuleEnabled('Mage_CatalogInventory')) {
193
+ $this->addColumn('qty',
194
+ array(
195
+ 'header'=> Mage::helper('catalog')->__('Qty'),
196
+ 'width' => '100px',
197
+ 'type' => 'number',
198
+ 'index' => 'qty',
199
+ ));
200
+ }
201
+
202
+ $this->addColumn('visibility',
203
+ array(
204
+ 'header'=> Mage::helper('catalog')->__('Visibility'),
205
+ 'width' => '140px',
206
+ 'index' => 'visibility',
207
+ 'type' => 'options',
208
+ 'options' => Mage::getModel('catalog/product_visibility')->getOptionArray(),
209
+ ));
210
+
211
+ $this->addColumn('status',
212
+ array(
213
+ 'header'=> Mage::helper('catalog')->__('Status'),
214
+ 'width' => '70px',
215
+ 'index' => 'status',
216
+ 'type' => 'options',
217
+ 'options' => Mage::getSingleton('catalog/product_status')->getOptionArray(),
218
+ ));
219
+
220
+ if (!Mage::app()->isSingleStoreMode()) {
221
+ $this->addColumn('websites',
222
+ array(
223
+ 'header'=> Mage::helper('catalog')->__('Websites'),
224
+ 'width' => '100px',
225
+ 'sortable' => false,
226
+ 'index' => 'websites',
227
+ 'type' => 'options',
228
+ 'options' => Mage::getModel('core/website')->getCollection()->toOptionHash(),
229
+ ));
230
+ }
231
+
232
+
233
+
234
+ return parent::_prepareColumns();
235
+ }
236
+
237
+ public function getGridUrl()
238
+ {
239
+ return $this->getUrl('*/*/grid', array('_current'=>true));
240
+ }
241
+
242
+ protected function _getSelectedProducts()
243
+ {
244
+ $products = "";
245
+ if($this->getRequest()->getParam('id')) {
246
+ $products = Mage::getModel('estimateddeliverydate/deliveries')->load($this->getRequest()->getParam('id'))->getPid();
247
+ }
248
+ return $products;
249
+ }
250
+
251
+ protected function _getStore()
252
+ {
253
+ $storeId = (int) $this->getRequest()->getParam('store', 0);
254
+ return Mage::app()->getStore($storeId);
255
+ }
256
+
257
+ }
app/code/community/Undottitled/Estimateddeliverydate/Block/Adminhtml/Deliveries/Edit/Tabs.php ADDED
@@ -0,0 +1,41 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Undottitled_Estimateddeliverydate_Block_Adminhtml_Deliveries_Edit_Tabs extends Mage_Adminhtml_Block_Widget_Tabs
3
+ {
4
+
5
+ public function __construct()
6
+ {
7
+ parent::__construct();
8
+ $this->setId('deliveries_info_tabs');
9
+ $this->setDestElementId('edit_form');
10
+ $this->setTitle(Mage::helper('estimateddeliverydate')->__('Deliveries Management'));
11
+ }
12
+
13
+ protected function _beforeToHtml()
14
+ {
15
+ $this->addTab('general', array(
16
+ 'label' => Mage::helper('estimateddeliverydate')->__('General Information'),
17
+ 'content' => $this->getLayout()->createBlock('estimateddeliverydate/adminhtml_deliveries_edit_tab_form')->initForm()->toHtml(),
18
+ 'active' => $this->getRequest()->getParam('id') ? false : true
19
+ ));
20
+
21
+ $this->addTab('product', array(
22
+ 'label' => Mage::helper('estimateddeliverydate')->__('Products'),
23
+ 'content' => $this->getLayout()->createBlock('estimateddeliverydate/adminhtml_deliveries_edit_tab_products')->toHtml()
24
+ ));
25
+
26
+ $this->_updateActiveTab();
27
+ Varien_Profiler::stop('estimateddeliverydate/tabs');
28
+ return parent::_beforeToHtml();
29
+ }
30
+
31
+ protected function _updateActiveTab()
32
+ {
33
+ $tabId = $this->getRequest()->getParam('tab');
34
+ if( $tabId ) {
35
+ $tabId = preg_replace("#{$this->getId()}_#", '', $tabId);
36
+ if($tabId) {
37
+ $this->setActiveTab($tabId);
38
+ }
39
+ }
40
+ }
41
+ }
app/code/community/Undottitled/Estimateddeliverydate/Block/Adminhtml/Deliveries/Grid.php ADDED
@@ -0,0 +1,75 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Undottitled_Estimateddeliverydate_Block_Adminhtml_Deliveries_Grid extends Mage_Adminhtml_Block_Widget_Grid
4
+ {
5
+ public function __construct()
6
+ {
7
+ parent::__construct();
8
+ $this->setId('deliveries_grid');
9
+ $this->setDefaultSort('id');
10
+ $this->setDefaultDir('desc');
11
+ $this->setSaveParametersInSession(true);
12
+ }
13
+
14
+ protected function _prepareCollection()
15
+ {
16
+ $collection = Mage::getModel('estimateddeliverydate/deliveries')->getCollection();
17
+ $this->setCollection($collection);
18
+ return parent::_prepareCollection();
19
+ }
20
+
21
+ protected function _prepareColumns()
22
+ {
23
+ $this->addColumn('id', array(
24
+ 'header' => Mage::helper('estimateddeliverydate')->__('ID'),
25
+ 'width' => '50px',
26
+ 'index' => 'id',
27
+ 'type' => 'number',
28
+ ));
29
+
30
+ $this->addColumn('pid', array(
31
+ 'header' => Mage::helper('estimateddeliverydate')->__('Product ID'),
32
+ 'width' => '50px',
33
+ 'index' => 'pid',
34
+ 'type' => 'number',
35
+ ));
36
+
37
+ $this->addColumn('sku', array(
38
+ 'header' => Mage::helper('estimateddeliverydate')->__('SKU'),
39
+ 'index' => 'sku',
40
+ 'type' => 'text'
41
+ ));
42
+
43
+ $this->addColumn('date', array(
44
+ 'header' => Mage::helper('estimateddeliverydate')->__('Delivery Date'),
45
+ 'index' => 'date',
46
+ 'type' => 'date',
47
+ ));
48
+
49
+ $this->addColumn('qty', array(
50
+ 'header' => Mage::helper('estimateddeliverydate')->__('Quantity Due'),
51
+ 'index' => 'qty',
52
+ 'type' => 'number',
53
+ ));
54
+
55
+ $this->addColumn('status', array(
56
+
57
+ 'header' => Mage::helper('estimateddeliverydate')->__('Status'),
58
+ 'align' => 'left',
59
+ 'width' => '80px',
60
+ 'index' => 'status',
61
+ 'type' => 'options',
62
+ 'options' => array(
63
+ 1 => 'Delivered',
64
+ 0 => 'Pending',
65
+ ),
66
+ ));
67
+
68
+ return parent::_prepareColumns();
69
+ }
70
+
71
+ public function getRowUrl($row)
72
+ {
73
+ return $this->getUrl('*/*/edit', array('id' => $row->getId()));
74
+ }
75
+ }
app/code/community/Undottitled/Estimateddeliverydate/Block/Display.php ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Undottitled_Estimateddeliverydate_Block_Display extends Mage_Core_Block_Template
4
+ {
5
+ const INITIAL_MSG_TEXT = "estimateddeliverydate/options/initial_message";
6
+ const FAILED_MSG_TEXT = "estimateddeliverydate/options/failed_request_message";
7
+ const MSG_ENABLED = "estimateddeliverydate/options/message_enabled";
8
+
9
+ public function getInitialMessage() {
10
+ return Mage::getStoreConfig(self::INITIAL_MSG_TEXT);
11
+ }
12
+
13
+ public function isEnabled() {
14
+ return Mage::getStoreConfig(self::MSG_ENABLED);
15
+ }
16
+
17
+ }
app/code/community/Undottitled/Estimateddeliverydate/Helper/Data.php ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Undottitled_Estimateddeliverydate_Helper_Data extends Mage_Core_Helper_Abstract
3
+ {
4
+ public function formatDate($date) {
5
+
6
+ $dateFormat = "d/m/Y"; // Needs changing to configurable in admin
7
+
8
+ if(empty($dateFormat)):
9
+ $dateFormat = Mage::getModel('core/locale')->getDateFormat();
10
+ endif;
11
+
12
+ return date($dateFormat,strtotime($date));
13
+ }
14
+ }
app/code/community/Undottitled/Estimateddeliverydate/Model/Deliveries.php ADDED
@@ -0,0 +1,61 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Undottitled_Estimateddeliverydate_Model_Deliveries extends Mage_Core_Model_Abstract
4
+ {
5
+ /**
6
+ * Intialize model
7
+ */
8
+ function _construct()
9
+ {
10
+ $this->_init('estimateddeliverydate/deliveries');
11
+ }
12
+
13
+
14
+
15
+ public function getNextDeliveryDate($pid,$qty) {
16
+
17
+ $stock = Mage::getModel('cataloginventory/stock_item');
18
+ $_currentStock = ($stock->loadByProduct($pid)->getStockQty()-$stock->getMinQty()); //Current stock - out of stock notification qty
19
+
20
+ if($_currentStock):
21
+ if($_currentStock >= $qty):
22
+ // Available immediately
23
+ return date("Y-m-d H:i:s",time());
24
+ else:
25
+ // Not enough in stock currently to handle the request
26
+ // Get items from the database to run checks
27
+ $allDates = $this->getDatesBySku($pid)->getData();
28
+ $rollingQty = $_currentStock;
29
+ if(!empty($allDates)):
30
+ foreach($allDates as $dateElement):
31
+ $rollingQty+= $dateElement['qty'];
32
+ if($rollingQty >= $qty):
33
+ return $dateElement['date'];
34
+ else:
35
+ continue;
36
+ endif;
37
+ endforeach;
38
+
39
+ return false;
40
+
41
+ endif;
42
+ endif;
43
+ else:
44
+ // Couldn't find current stock level
45
+ return false;
46
+ endif;
47
+ }
48
+
49
+
50
+ public function getDatesBySku($pid)
51
+ {
52
+ $data = $this->getResource()->getDatesBySku($pid);
53
+
54
+ if (is_array($data)) {
55
+ $this->addData($data);
56
+ }
57
+ return $this;
58
+ }
59
+
60
+
61
+ }
app/code/community/Undottitled/Estimateddeliverydate/Model/Mysql4/Deliveries.php ADDED
@@ -0,0 +1,4 @@
 
 
 
 
1
+ <?php
2
+ class Undottitled_Estimateddeliverydate_Model_Mysql4_Deliveries extends Undottitled_Estimateddeliverydate_Model_Resource_Message
3
+ {
4
+ }
app/code/community/Undottitled/Estimateddeliverydate/Model/Mysql4/Deliveries/Collection.php ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
1
+ <?php
2
+
3
+ class Undottitled_Estimateddeliverydate_Model_Mysql4_Deliveries_Collection extends Undottitled_Estimateddeliverydate_Model_Resource_Message_Collection
4
+ {
5
+ }
app/code/community/Undottitled/Estimateddeliverydate/Model/Resource/Deliveries.php ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Undottitled_Estimateddeliverydate_Model_Resource_Deliveries extends Mage_Core_Model_Resource_Db_Abstract
4
+ {
5
+
6
+ /**
7
+ * Intialize resource model.
8
+ * Set main entity table name and primary key field name.
9
+ *
10
+ */
11
+ protected function _construct()
12
+ {
13
+ $this->_init('estimateddeliverydate/deliveries', 'id');
14
+ }
15
+
16
+
17
+ public function getDatesBySku($pid)
18
+ {
19
+
20
+ $select = $this->_getReadAdapter()->select()
21
+ ->from($this->getMainTable(), array('*'))
22
+ ->where('pid = ?', $pid)
23
+ ->order('date','ASC');
24
+ return $this->_getReadAdapter()->fetchAll($select);
25
+ }
26
+
27
+ }
app/code/community/Undottitled/Estimateddeliverydate/Model/Resource/Deliveries/Collection.php ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Undottitled_Estimateddeliverydate_Model_Resource_Deliveries_Collection extends Mage_Core_Model_Resource_Db_Collection_Abstract
4
+ {
5
+ /**
6
+ * Collection constructor
7
+ *
8
+ */
9
+ protected function _construct()
10
+ {
11
+ $this->_init('estimateddeliverydate/deliveries');
12
+ }
13
+ }
app/code/community/Undottitled/Estimateddeliverydate/controllers/Adminhtml/DeliveriesController.php ADDED
@@ -0,0 +1,138 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Undottitled_Estimateddeliverydate_Adminhtml_DeliveriesController extends Mage_Adminhtml_Controller_Action
4
+ {
5
+
6
+ protected function _initAction()
7
+ {
8
+ $this->loadLayout()
9
+ ->_setActiveMenu('estimateddeliverydate/deliveries')
10
+ ->_addBreadcrumb(Mage::helper('adminhtml')->__('Retailer Management'), Mage::helper('adminhtml')->__('Delivery Date Management'));
11
+ return $this;
12
+ }
13
+
14
+ public function indexAction() {
15
+ $this->_initAction();
16
+
17
+ $this->_addContent(
18
+ $this->getLayout()->createBlock('estimateddeliverydate/adminhtml_deliveries', 'deliveries')
19
+ );
20
+ $this->renderLayout();
21
+ }
22
+
23
+
24
+ public function newAction() {
25
+ $this->_forward('edit');
26
+ }
27
+
28
+
29
+ public function editAction() {
30
+ $this->_initAction();
31
+ $deliveriesModel = Mage::getModel('estimateddeliverydate/deliveries')->load($this->getRequest()->getParam('id'));
32
+
33
+ if ($deliveriesModel->getId()) {
34
+ Mage::register('deliveries_data', $deliveriesModel);
35
+
36
+ $this->loadLayout();
37
+ $this->_setActiveMenu('deliveries/items');
38
+
39
+ $this->getLayout()->getBlock('head')->setCanLoadExtJs(true);
40
+
41
+ $this->_addContent($this->getLayout()->createBlock('estimateddeliverydate/adminhtml_deliveries_edit', 'deliveries'))
42
+ ->_addLeft($this->getLayout()->createBlock('estimateddeliverydate/adminhtml_deliveries_edit_tabs'));
43
+
44
+ $this->renderLayout();
45
+ } else {
46
+ $this->loadLayout();
47
+ $this->_setActiveMenu('deliveries/items');
48
+
49
+ $this->getLayout()->getBlock('head')->setCanLoadExtJs(true);
50
+
51
+ $this->_addContent($this->getLayout()->createBlock('estimateddeliverydate/adminhtml_deliveries_edit', 'deliveries'))
52
+ ->_addLeft($this->getLayout()->createBlock('estimateddeliverydate/adminhtml_deliveries_edit_tabs'));
53
+
54
+ $this->renderLayout();
55
+ }
56
+ }
57
+
58
+ public function saveAction() {
59
+ if ($this->getRequest()->getPost() ) {
60
+ try {
61
+ $postData = $this->getRequest()->getPost();
62
+
63
+ if($postData['in_products']) {
64
+ $product = Mage::getModel("catalog/product")->load($postData['in_products']);
65
+ if($product) {
66
+ $postData['pid'] = $product->getId();
67
+ $postData['sku'] = $product->getSku();
68
+ } else {
69
+ $postData['pid'] = "";
70
+ $postData['sku'] = "";
71
+ }
72
+ }
73
+
74
+ $deliveriesModel = Mage::getModel('estimateddeliverydate/deliveries');
75
+ if($postData['date'] != NULL)
76
+ {
77
+ $date1 = Mage::app()->getLocale()->date($postData['date'], Zend_Date::DATETIME_SHORT);
78
+ $postData['date'] = ($date1->toString('YYYY-MM-dd HH:mm:ss'));
79
+ }
80
+ if($this->getRequest()->getParam('id')) {
81
+ $deliveriesModel->setId($this->getRequest()->getParam('id'))->addData($postData);
82
+ $deliveriesModel->save();
83
+ $message = "Delivery was successfully updated";
84
+ } else {
85
+ unset($postData['id']);
86
+ $deliveriesModel->addData($postData);
87
+ $deliveriesModel->save();
88
+ $message = "Delivery was successfully saved";
89
+ }
90
+
91
+ Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('adminhtml')->__($message));
92
+ Mage::getSingleton('adminhtml/session')->setDeliveriesData(false);
93
+ if(!isset($chgRedirect)) {
94
+ $this->_redirect('*/*/index');
95
+ } else {
96
+ $this->_redirect('*/*/edit', array('id' => $this->getRequest()->getParam('id')));
97
+ }
98
+ return;
99
+ } catch (Exception $e) {
100
+ Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
101
+ Mage::getSingleton('adminhtml/session')->setDeliveriesData($this->getRequest()->getPost());
102
+ $this->_redirect('*/*/edit', array('id' => $this->getRequest()->getParam('id')));
103
+ return;
104
+ }
105
+ }
106
+ $this->_redirect('*/*/index');
107
+ }
108
+
109
+ public function deleteAction() {
110
+ $model = Mage::getModel('estimateddeliverydate/deliveries');
111
+ $id = $this->getRequest()->getParam('id');
112
+
113
+ try {
114
+ if ($id) {
115
+ if (!$model->load($id)->getId()) {
116
+ Mage::throwException($this->__('No record with ID "%s" found.', $id));
117
+ }
118
+ $sku = $model->getSku();
119
+ $model->delete();
120
+ $this->_getSession()->addSuccess($this->__('"%s" (Delivery ID: %d) was successfully deleted', $sku, $id));
121
+ $this->_redirect('*/*');
122
+ }
123
+ } catch (Exception $e) {
124
+ Mage::logException($e);
125
+ $this->_getSession()->addError($e->getMessage());
126
+ $this->_redirect('*/*');
127
+ }
128
+ }
129
+
130
+ public function gridAction()
131
+ {
132
+ $blockMarkup = $this->getLayout()->createBlock('estimateddeliverydate/adminhtml_deliveries_edit_tab_products')->toHtml();
133
+ $this->getResponse()->setBody($blockMarkup);
134
+
135
+ }
136
+
137
+
138
+ }
app/code/community/Undottitled/Estimateddeliverydate/controllers/IndexController.php ADDED
@@ -0,0 +1,30 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Undottitled_Estimateddeliverydate_IndexController extends Mage_Core_Controller_Front_Action
4
+ {
5
+
6
+ protected function _getHelper()
7
+ {
8
+ return Mage::helper('estimateddeliverydate');
9
+ }
10
+
11
+
12
+ public function getdeliveriesAction() {
13
+
14
+ $model = Mage::getModel('estimateddeliverydate/deliveries');
15
+
16
+ $params = $this->getRequest()->getParams();
17
+ if(!$params['qty'] > 0) $params['qty'] = 1;
18
+ if(!empty($params['pid'])):
19
+ $deliveryDate = $model->getNextDeliveryDate($params['pid'],$params['qty']);
20
+
21
+ if($deliveryDate == false):
22
+ echo $this->_getHelper()->__(Mage::getStoreConfig("estimateddeliverydate/options/failed_request_message"));
23
+ else:
24
+ echo $this->_getHelper()->formatDate($deliveryDate);
25
+ endif;
26
+ else:
27
+ echo $this->_getHelper()->__(Mage::getStoreConfig("estimateddeliverydate/options/failed_request_message"));
28
+ endif;
29
+ }
30
+ }
app/code/community/Undottitled/Estimateddeliverydate/etc/adminhtml.xml ADDED
@@ -0,0 +1,34 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <menu>
4
+ <catalog translate="title" module="catalog">
5
+ <children>
6
+ <deliveries translate="title" module="estimateddeliverydate">
7
+ <title>Manage Product Delivery Dates</title>
8
+ <sort_order>1</sort_order>
9
+ <action>adminhtml/deliveries/index</action>
10
+ </deliveries>
11
+ </children>
12
+ </catalog>
13
+ </menu>
14
+
15
+ <acl>
16
+ <resources>
17
+ <admin>
18
+ <children>
19
+ <system>
20
+ <children>
21
+ <config>
22
+ <children>
23
+ <estimateddeliverydate translate="title" module="estimateddeliverydate">
24
+ <title>Estimated Delivery Dates Section</title>
25
+ </estimateddeliverydate>
26
+ </children>
27
+ </config>
28
+ </children>
29
+ </system>
30
+ </children>
31
+ </admin>
32
+ </resources>
33
+ </acl>
34
+ </config>
app/code/community/Undottitled/Estimateddeliverydate/etc/config.xml ADDED
@@ -0,0 +1,109 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <modules>
4
+ <Undottitled_Estimateddeliverydate>
5
+ <version>0.1.0</version>
6
+ </Undottitled_Estimateddeliverydate>
7
+ </modules>
8
+
9
+ <frontend>
10
+ <routers>
11
+ <estimateddeliverydate>
12
+ <use>standard</use>
13
+ <args>
14
+ <module>Undottitled_Estimateddeliverydate</module>
15
+ <frontName>estimateddeliverydate</frontName>
16
+ </args>
17
+ </estimateddeliverydate>
18
+ </routers>
19
+ <layout>
20
+ <updates>
21
+ <estimateddeliverydate>
22
+ <file>estimateddeliverydate.xml</file>
23
+ </estimateddeliverydate>
24
+ </updates>
25
+ </layout>
26
+ </frontend>
27
+
28
+
29
+ <admin>
30
+ <routers>
31
+ <adminhtml>
32
+ <args>
33
+ <modules>
34
+ <estimateddeliverydate before="Mage_Adminhtml">Undottitled_Estimateddeliverydate_Adminhtml</estimateddeliverydate>
35
+ </modules>
36
+ </args>
37
+ </adminhtml>
38
+ </routers>
39
+ </admin>
40
+
41
+
42
+ <global>
43
+ <blocks>
44
+ <estimateddeliverydate>
45
+ <class>Undottitled_Estimateddeliverydate_Block</class>
46
+ </estimateddeliverydate>
47
+ </blocks>
48
+ <helpers>
49
+ <estimateddeliverydate>
50
+ <class>Undottitled_Estimateddeliverydate_Helper</class>
51
+ </estimateddeliverydate>
52
+ </helpers>
53
+ <models>
54
+ <estimateddeliverydate>
55
+ <class>Undottitled_Estimateddeliverydate_Model</class>
56
+ <resourceModel>estimateddeliverydate_resource</resourceModel>
57
+ </estimateddeliverydate>
58
+ <estimateddeliverydate_resource>
59
+ <class>Undottitled_Estimateddeliverydate_Model_Resource</class>
60
+ <deprecatedNode>estimateddeliverydate_mysql4</deprecatedNode>
61
+ <entities>
62
+ <deliveries>
63
+ <table>estimateddeliverydate_data</table>
64
+ </deliveries>
65
+ </entities>
66
+ </estimateddeliverydate_resource>
67
+ </models>
68
+
69
+ <resources>
70
+ <estimateddeliverydate_setup>
71
+ <setup>
72
+ <module>Undottitled_Estimateddeliverydate</module>
73
+ </setup>
74
+ <connection>
75
+ <use>core_setup</use>
76
+ </connection>
77
+ </estimateddeliverydate_setup>
78
+ <estimateddeliverydate_write>
79
+ <connection>
80
+ <use>core_write</use>
81
+ </connection>
82
+ </estimateddeliverydate_write>
83
+ <estimateddeliverydate_read>
84
+ <connection>
85
+ <use>core_read</use>
86
+ </connection>
87
+ </estimateddeliverydate_read>
88
+ </resources>
89
+ </global>
90
+
91
+ <adminhtml>
92
+ <layout>
93
+ <updates>
94
+ <estimateddeliverydate>
95
+ <file>estimateddeliverydate.xml</file>
96
+ </estimateddeliverydate>
97
+ </updates>
98
+ </layout>
99
+ </adminhtml>
100
+
101
+ <default>
102
+ <estimateddeliverydate>
103
+ <options>
104
+ <initial_message><![CDATA[Please select options to check delivery.]]></initial_message>
105
+ <failed_request_message><![CDATA[An estimated delivery date for this product is currently unavailable.]]></failed_request_message>
106
+ </options>
107
+ </estimateddeliverydate>
108
+ </default>
109
+ </config>
app/code/community/Undottitled/Estimateddeliverydate/etc/system.xml ADDED
@@ -0,0 +1,56 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <config>
2
+ <sections>
3
+ <estimateddeliverydate translate="label" module="estimateddeliverydate">
4
+ <label>Estimate Delivery Dates</label>
5
+ <tab>catalog</tab>
6
+ <frontend_type>text</frontend_type>
7
+ <sort_order>51</sort_order>
8
+ <show_in_default>1</show_in_default>
9
+ <show_in_website>1</show_in_website>
10
+ <show_in_store>1</show_in_store>
11
+ <groups>
12
+ <options translate="label">
13
+ <label>Defaults</label>
14
+ <frontend_type>text</frontend_type>
15
+ <sort_order>1</sort_order>
16
+ <show_in_default>1</show_in_default>
17
+ <show_in_website>1</show_in_website>
18
+ <show_in_store>1</show_in_store>
19
+ <fields>
20
+ <message_enabled translate="label">
21
+ <label>Enable displaying of delivery message</label>
22
+ <frontend_type>select</frontend_type>
23
+ <source_model>adminhtml/system_config_source_yesno</source_model>
24
+ <backend_model>adminhtml/system_config_backend_store</backend_model>
25
+ <default>1</default>
26
+ <sort_order>10</sort_order>
27
+ <show_in_default>1</show_in_default>
28
+ <show_in_website>1</show_in_website>
29
+ <show_in_store>1</show_in_store>
30
+ <comment><![CDATA[Display the estimated delivery message on the frontend.]]></comment>
31
+ </message_enabled>
32
+ <initial_message translate="label">
33
+ <label>Initial Displayed Message</label>
34
+ <frontend_type>text</frontend_type>
35
+ <sort_order>20</sort_order>
36
+ <show_in_default>1</show_in_default>
37
+ <show_in_website>1</show_in_website>
38
+ <show_in_store>1</show_in_store>
39
+ <default_value>asdasd</default_value>
40
+ </initial_message>
41
+ <failed_request_message translate="label">
42
+ <label>Failed Request Message</label>
43
+ <frontend_type>text</frontend_type>
44
+ <sort_order>30</sort_order>
45
+ <show_in_default>1</show_in_default>
46
+ <show_in_website>1</show_in_website>
47
+ <show_in_store>1</show_in_store>
48
+ <default>An estimated delivery date for this product is currently unavailable.</default>
49
+ </failed_request_message>
50
+ </fields>
51
+ </options>
52
+ </groups>
53
+ </estimateddeliverydate>
54
+ </sections>
55
+ </config>
56
+
app/code/community/Undottitled/Estimateddeliverydate/sql/estimateddeliverydate_setup/install-0.1.0.php ADDED
@@ -0,0 +1,56 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ $installer = $this;
3
+ /* @var $installer Mage_Catalog_Model_Resource_Setup */
4
+
5
+ $installer->startSetup();
6
+ /**
7
+ * Create table 'catalog/product'
8
+ */
9
+
10
+ /* CODE FOR USE WITH Magento CE 1.7+ */
11
+ /*$table = $installer->getConnection()
12
+ ->newTable($installer->getTable('estimateddeliverydate/deliveries'))
13
+ ->addColumn('id', Varien_Db_Ddl_Table::TYPE_INTEGER, null, array(
14
+ 'identity' => true,
15
+ 'unsigned' => true,
16
+ 'nullable' => false,
17
+ 'primary' => true,
18
+ ), 'Entity ID')
19
+ ->addColumn('pid', Varien_Db_Ddl_Table::TYPE_INTEGER, null, array(
20
+ 'unsigned' => true,
21
+ 'nullable' => true,
22
+ ), 'Product Entity ID')
23
+ ->addColumn('sku', Varien_Db_Ddl_Table::TYPE_TEXT, 255, array(
24
+ 'nullable' => false,
25
+ ), 'Product SKU')
26
+ ->addColumn('date', Varien_Db_Ddl_Table::TYPE_DATETIME, null, array(
27
+ ), 'Delivery Date')
28
+ ->addColumn('qty', Varien_Db_Ddl_Table::TYPE_DECIMAL, '12,2', array(
29
+ 'unsigned' => true,
30
+ 'nullable' => true,
31
+ ), 'Delivery Qty')
32
+ ->addColumn('status', Varien_Db_Ddl_Table::TYPE_SMALLINT, null, array(
33
+ 'unsigned' => true,
34
+ 'nullable' => false,
35
+ 'default' => '0'
36
+ ), 'Delivery Status')
37
+ ->setComment('Catalog Product Datetime Attribute Backend Table');
38
+ $installer->getConnection()->createTable($table);
39
+
40
+ $installer->endSetup();*/
41
+
42
+
43
+ $installer->run("
44
+
45
+ DROP TABLE IF EXISTS {$this->getTable('estimateddeliverydate/deliveries')};
46
+ CREATE TABLE `{$this->getTable('estimateddeliverydate/deliveries')}` (
47
+ `id` int(10) unsigned NOT NULL AUTO_INCREMENT COMMENT 'Entity ID',
48
+ `pid` int(10) unsigned DEFAULT NULL COMMENT 'Product Entity ID',
49
+ `sku` varchar(255) NOT NULL COMMENT 'Product SKU',
50
+ `date` datetime DEFAULT NULL COMMENT 'Delivery Date',
51
+ `qty` decimal(12,2) DEFAULT NULL COMMENT 'Delivery Qty',
52
+ `status` smallint(5) unsigned NOT NULL DEFAULT '0' COMMENT 'Delivery Status',
53
+ PRIMARY KEY (`id`)
54
+ ) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8 COMMENT='Catalog Product Datetime Attribute Backend Table';");
55
+
56
+ $installer->endSetup();
app/design/frontend/base/default/layout/estimateddeliverydate.xml ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <layout version="0.1.0">
2
+
3
+ <catalog_product_view translate="label">
4
+ <reference name="head">
5
+ <action method="addJs"><script>undottitled/estimateddeliverydate/estimateddeliverydate.js</script></action>
6
+ </reference>
7
+ </catalog_product_view>
8
+
9
+ <PRODUCT_TYPE_simple translate="label" module="catalog">
10
+ <reference name="product.info.addtocart">
11
+ <block type="estimateddeliverydate/display" name="estimateddeliverydate" as="estimateddeliverydate" template="estimateddeliverydate/catalog/product/view/estimateddeliverydate_simple.phtml" />
12
+ </reference>
13
+ </PRODUCT_TYPE_simple>
14
+ <PRODUCT_TYPE_configurable translate="label" module="catalog">
15
+ <reference name="product.info.addtocart">
16
+ <block type="estimateddeliverydate/display" name="estimateddeliverydate" as="estimateddeliverydate" template="estimateddeliverydate/catalog/product/view/estimateddeliverydate.phtml" />
17
+ </reference>
18
+ </PRODUCT_TYPE_configurable>
19
+
20
+ </layout>
app/design/frontend/base/default/template/estimateddeliverydate/catalog/product/view/estimateddeliverydate.phtml ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ if($this->isEnabled()):
3
+ ?>
4
+ <br />&nbsp;
5
+ <div id="estimatedDeliveryContainer">
6
+ <strong><?php echo $this->__('Estimated Delivery:'); ?></strong>
7
+ <div id="estimatedDeliveryText"><em><?php echo $this->__($this->getInitialMessage()); ?></em></div>
8
+ </div>
9
+ <?php
10
+ endif;
11
+ ?>
app/design/frontend/base/default/template/estimateddeliverydate/catalog/product/view/estimateddeliverydate_simple.phtml ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ if($this->isEnabled()):
3
+ ?>
4
+ <br />&nbsp;
5
+ <div id="estimatedDeliveryContainer">
6
+ <strong><?php echo $this->__('Estimated Delivery:'); ?></strong>
7
+ <div id="estimatedDeliveryText"><em><?php echo $this->__($this->getInitialMessage()); ?></em></div>
8
+ </div>
9
+ <script type="text/javascript">
10
+ document.observe('dom:loaded',function() {
11
+ updateDeliveryDate_Simple(document.getElementsByName('product')[0].value); }
12
+ );
13
+ </script>
14
+ <?php
15
+ endif;
16
+ ?>
app/etc/modules/Undottitled_Estimateddeliverydate.xml ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <!--
3
+ /**
4
+ * Magento
5
+ *
6
+ * NOTICE OF LICENSE
7
+ *
8
+ * This source file is subject to the Open Software License (OSL 3.0)
9
+ * that is bundled with this package in the file LICENSE.txt.
10
+ * It is also available through the world-wide-web at this URL:
11
+ * http://opensource.org/licenses/osl-3.0.php
12
+ * If you did not receive a copy of the license and are unable to
13
+ * obtain it through the world-wide-web, please send an email
14
+ * to license@magentocommerce.com so we can send you a copy immediately.
15
+ *
16
+ * @category Undottitled
17
+ * @package Undottitled_Estimatedeliverydate
18
+ * @copyright Copyright (c) 2012 Un.titled (www.un.titled.co.uk)
19
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
20
+ */
21
+ -->
22
+ <config>
23
+ <modules>
24
+ <Undottitled_Estimateddeliverydate>
25
+ <active>true</active>
26
+ <codePool>community</codePool>
27
+ </Undottitled_Estimateddeliverydate>
28
+ </modules>
29
+ </config>
js/undottitled/estimateddeliverydate/estimateddeliverydate.js ADDED
@@ -0,0 +1,50 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ var host = window.location.protocol+"//"+window.location.host+"/";
2
+ document.observe('dom:loaded',function() {
3
+ $$('.product-options dd.last').each(function(el) {
4
+ var finalAttribute = $(el).children[0].children[0];
5
+ $(finalAttribute.id).observe('change',function(event) {
6
+ var ele = Event.element(event);
7
+ updateDeliveryDate(ele);
8
+ });
9
+ });
10
+
11
+ $('qty').observe('keyup',function() {
12
+ if($('product-options-wrapper')) {
13
+ console.log('asd');
14
+ $$('.product-options dd.last').each(function(el) {
15
+ var finalAttribute = $(el).children[0].children[0];
16
+
17
+ var ele = $(finalAttribute.id);
18
+ updateDeliveryDate(ele);
19
+ });
20
+ } else {
21
+ updateDeliveryDate_Simple(document.getElementsByName('product')[0].value);q
22
+ }
23
+
24
+ });
25
+ });
26
+
27
+
28
+ function updateDeliveryDate(ele) {
29
+ var eleTrimmedId = $(ele).id.replace('attribute','');
30
+ var jsonConfig = spConfig.config.attributes[eleTrimmedId].options;
31
+ jsonConfig.each(function(obj) {
32
+ if(obj.id == ele.value) {
33
+ new Ajax.Request(host+'estimateddeliverydate/index/getdeliveries/pid/'+obj.allowedProducts[0]+'/qty/'+$('qty').value, {
34
+ onSuccess: function(response) {
35
+ $('estimatedDeliveryText').update(response.responseText);
36
+ }
37
+ });
38
+ } else {
39
+ $('estimatedDeliveryText').update('Please select options to check delivery');
40
+ }
41
+ });
42
+ }
43
+
44
+ function updateDeliveryDate_Simple(pid) {
45
+ new Ajax.Request(host+'estimateddeliverydate/index/getdeliveries/pid/'+pid+'/qty/'+$('qty').value, {
46
+ onSuccess: function(response) {
47
+ $('estimatedDeliveryText').update(response.responseText);
48
+ }
49
+ });
50
+ }
package.xml ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <package>
3
+ <name>estimateddeliverydate</name>
4
+ <version>0.1.0</version>
5
+ <stability>stable</stability>
6
+ <license>OSL v3.0</license>
7
+ <channel>community</channel>
8
+ <extends/>
9
+ <summary>Allow you customers to find around a more exact delivery date for their goods based on deliveries from your suppliers.</summary>
10
+ <description>With this simple to implement extension you can enter the dates you're expecting to get items in stock and allow your customers to see when they're likely to get their items based on the quantity they require.&#xD;
11
+ &#xD;
12
+ Currently the extension works with configurable and simple products only.</description>
13
+ <notes>Please test thoroughly on a non-live platform before using in a production environment.</notes>
14
+ <authors><author><name>Un.titled</name><user>undottitled</user><email>tech@un.titled.co.uk</email></author></authors>
15
+ <date>2012-05-16</date>
16
+ <time>11:29:41</time>
17
+ <contents><target name="magecommunity"><dir name="Undottitled"><dir name="Estimateddeliverydate"><dir><dir name="Block"><dir name="Adminhtml"><dir name="Deliveries"><dir name="Edit"><file name="Form.php" hash="1b75f149874c6f1fa2d2e23c5d19c1f3"/><dir name="Tab"><file name="Form.php" hash="b0da75f24485e2f8033845ac4c48c1c5"/><file name="Products.php" hash="d8903ef42b7686ead9209802da9db498"/></dir><file name="Tabs.php" hash="f8ff0828f398883a6b72e3330bb67198"/></dir><file name="Edit.php" hash="9df63601f5012892b9ee7fe7383b9fa1"/><file name="Grid.php" hash="a4ca1a7ccb04c86696199612f4e3dde0"/></dir><file name="Deliveries.php" hash="6284c9021fc5e6a4a997d7d3dc4c62fb"/></dir><file name="Display.php" hash="28f7010da385a8d73b626b82b76011be"/></dir><dir name="Helper"><file name="Data.php" hash="bc432e37d4f2e4a90a0cc31e485e11e9"/></dir><dir name="Model"><file name="Deliveries.php" hash="96fcc7a9234fd946dbe1d0f4644f2c27"/><dir name="Mysql4"><dir name="Deliveries"><file name="Collection.php" hash="980989a78a8808fac57ddfd146f790d2"/></dir><file name="Deliveries.php" hash="b152a916d7f0bba455da7c69691f1a68"/></dir><dir name="Resource"><dir name="Deliveries"><file name="Collection.php" hash="4094fd6cff794b28355ab4d3238367a2"/></dir><file name="Deliveries.php" hash="f92b784e779194b73f8b928b5a2b83d9"/></dir></dir><dir name="controllers"><dir name="Adminhtml"><file name="DeliveriesController.php" hash="03421338b05c28a02ecb554bb09a21ff"/></dir><file name="IndexController.php" hash="94cf594e39f7a55e49254f6637fdb724"/></dir><dir name="etc"><file name="adminhtml.xml" hash="f5a41b6f6065db31792bef9bb7fd06cb"/><file name="config.xml" hash="1062077d5474afca40f6166adc0c1170"/><file name="system.xml" hash="cea0c48c0905a65976c07bfa9badd9db"/></dir><dir name="sql"><dir name="estimateddeliverydate_setup"><file name="install-0.1.0.php" hash="f52380d9f97bf6b8667c33bfa1507c20"/></dir></dir></dir></dir></dir></target><target name="magedesign"><dir name="frontend"><dir name="base"><dir name="default"><dir name="layout"><file name="estimateddeliverydate.xml" hash="e137375f417f1ebc51f702b37a9bbfc6"/></dir><dir name="template"><dir name="estimateddeliverydate"><dir name="catalog"><dir name="product"><dir name="view"><file name="estimateddeliverydate.phtml" hash="eacb8f77e3c02b07f46708d6a6586cba"/><file name="estimateddeliverydate_simple.phtml" hash="694fdbb15515c283fd923173c999f39c"/></dir></dir></dir></dir></dir></dir></dir></dir></target><target name="mageweb"><dir name="js"><dir name="undottitled"><dir name="estimateddeliverydate"><file name="estimateddeliverydate.js" hash="52b07cc7763c650e363591ed8ae55e2a"/></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Undottitled_Estimateddeliverydate.xml" hash="5f93ba5d50b3f9b5f73aafbc46141857"/></dir></target></contents>
18
+ <compatible/>
19
+ <dependencies><required><php><min>5.1.0</min><max>6.0.0</max></php><package><name>Mage_Core_Modules</name><channel>community</channel><min>1.5.0</min><max>1.7</max></package></required></dependencies>
20
+ </package>