Version Notes
First stable release.
Download this release
Release Info
Developer | Magento Core Team |
Extension | soonstockreleaser |
Version | 1.0.0 |
Comparing to | |
See all releases |
Version 1.0.0
- app/code/community/Soon/StockReleaser/Block/Adminhtml/Sales/Order/Canceled.php +22 -0
- app/code/community/Soon/StockReleaser/Block/Adminhtml/Sales/Order/Canceled/Grid.php +122 -0
- app/code/community/Soon/StockReleaser/Block/Adminhtml/System/Config/Form.php +249 -0
- app/code/community/Soon/StockReleaser/Helper/Data.php +14 -0
- app/code/community/Soon/StockReleaser/Model/Cancel.php +123 -0
- app/code/community/Soon/StockReleaser/Model/Mysql4/Cancel.php +18 -0
- app/code/community/Soon/StockReleaser/Model/Mysql4/Cancel/Collection.php +52 -0
- app/code/community/Soon/StockReleaser/Model/Observer.php +52 -0
- app/code/community/Soon/StockReleaser/Model/System/Config/Source/Order/Status.php +21 -0
- app/code/community/Soon/StockReleaser/Model/System/Config/Source/Unit.php +28 -0
- app/code/community/Soon/StockReleaser/controllers/Adminhtml/Sales/Order/CanceledController.php +50 -0
- app/code/community/Soon/StockReleaser/etc/config.xml +176 -0
- app/code/community/Soon/StockReleaser/etc/system.xml +63 -0
- app/code/community/Soon/StockReleaser/sql/stockreleaser_setup/mysql4-install-0.1.0.php +28 -0
- app/code/community/Soon/StockReleaser/todo.txt +19 -0
- app/design/adminhtml/default/default/layout/stockreleaser.xml +24 -0
- app/etc/modules/Soon_StockReleaser.xml +9 -0
- app/locale/fr_FR/Soon_StockReleaser.csv +24 -0
- package.xml +42 -0
app/code/community/Soon/StockReleaser/Block/Adminhtml/Sales/Order/Canceled.php
ADDED
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Agence Soon
|
5 |
+
*
|
6 |
+
* @category Soon
|
7 |
+
* @package Soon_StockReleaser
|
8 |
+
* @copyright Copyright (c) 2011 Agence Soon. (http://www.agence-soon.fr)
|
9 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
10 |
+
* @author Hervé Guétin
|
11 |
+
*
|
12 |
+
*/
|
13 |
+
class Soon_StockReleaser_Block_Adminhtml_Sales_Order_Canceled extends Mage_Adminhtml_Block_Sales_Order {
|
14 |
+
|
15 |
+
public function __construct() {
|
16 |
+
parent::__construct();
|
17 |
+
$this->_controller = 'adminhtml_sales_order_canceled';
|
18 |
+
$this->_blockGroup = 'stockreleaser';
|
19 |
+
$this->_headerText = Mage::helper('sales')->__('Automatically Canceled Orders');
|
20 |
+
}
|
21 |
+
|
22 |
+
}
|
app/code/community/Soon/StockReleaser/Block/Adminhtml/Sales/Order/Canceled/Grid.php
ADDED
@@ -0,0 +1,122 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Agence Soon
|
5 |
+
*
|
6 |
+
* @category Soon
|
7 |
+
* @package Soon_StockReleaser
|
8 |
+
* @copyright Copyright (c) 2011 Agence Soon. (http://www.agence-soon.fr)
|
9 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
10 |
+
* @author Hervé Guétin
|
11 |
+
*/
|
12 |
+
class Soon_StockReleaser_Block_Adminhtml_Sales_Order_Canceled_Grid extends Mage_Adminhtml_Block_Sales_Order_Grid {
|
13 |
+
|
14 |
+
public function __construct() {
|
15 |
+
parent::__construct();
|
16 |
+
$this->setId('sales_order_canceled_grid');
|
17 |
+
$this->setDefaultSort('autocancel_date');
|
18 |
+
}
|
19 |
+
|
20 |
+
/**
|
21 |
+
* Prepare collection with automatically canceled orders
|
22 |
+
*
|
23 |
+
* @return Mage_Adminhtml_Block_Widget_Grid
|
24 |
+
*/
|
25 |
+
protected function _prepareCollection() {
|
26 |
+
$collection = Mage::getResourceModel($this->_getCollectionClass());
|
27 |
+
|
28 |
+
$collection->getSelect()->joinLeft(array('autocancel_order' => 'stockreleaser_cancel'), 'autocancel_order.order_id=main_table.entity_id');
|
29 |
+
$collection->addFieldToFilter('autocancel_order.autocancel_status', 1);
|
30 |
+
|
31 |
+
$this->setCollection($collection);
|
32 |
+
|
33 |
+
return Mage_Adminhtml_Block_Widget_Grid::_prepareCollection();
|
34 |
+
}
|
35 |
+
|
36 |
+
/**
|
37 |
+
* Update existing colums from Mage_Adminhtml_Block_Sales_Order_Grid
|
38 |
+
*
|
39 |
+
* @return Mage_Adminhtml_Block_Widget_Grid
|
40 |
+
*/
|
41 |
+
protected function _prepareColumns() {
|
42 |
+
parent::_prepareColumns();
|
43 |
+
|
44 |
+
$this->addColumnAfter('autocancel_date', array(
|
45 |
+
'header' => Mage::helper('stockreleaser')->__('Canceled On'),
|
46 |
+
'index' => 'autocancel_date',
|
47 |
+
'type' => 'datetime',
|
48 |
+
'width' => '100px',
|
49 |
+
), 'created_at');
|
50 |
+
|
51 |
+
if (version_compare(Mage::getVersion(), '1.6.0.0', '>=')){
|
52 |
+
$this->removeColumn('status');
|
53 |
+
}
|
54 |
+
else {
|
55 |
+
$this->removeColumnAlt('status');
|
56 |
+
}
|
57 |
+
|
58 |
+
$this->_updateActions();
|
59 |
+
|
60 |
+
return Mage_Adminhtml_Block_Widget_Grid::_prepareColumns();
|
61 |
+
}
|
62 |
+
|
63 |
+
/**
|
64 |
+
* @deprecated since version 1.6.0.0 see Mage_Adminhtml_Block_Widget_Grid::removeColmun()
|
65 |
+
*
|
66 |
+
* Remove existing column
|
67 |
+
*
|
68 |
+
* @param string $columnId
|
69 |
+
* @return Soon_StockReleaser_Block_Adminhtml_Sales_Order_Canceled_Grid
|
70 |
+
*/
|
71 |
+
public function removeColumnAlt($columnId)
|
72 |
+
{
|
73 |
+
if (isset($this->_columns[$columnId])) {
|
74 |
+
unset($this->_columns[$columnId]);
|
75 |
+
if ($this->_lastColumnId == $columnId) {
|
76 |
+
$this->_lastColumnId = key($this->_columns);
|
77 |
+
}
|
78 |
+
}
|
79 |
+
return $this;
|
80 |
+
}
|
81 |
+
|
82 |
+
/**
|
83 |
+
* Change the link to open order view
|
84 |
+
*
|
85 |
+
* @return Soon_StockReleaser_Block_Adminhtml_Sales_Order_Canceled_Grid
|
86 |
+
*/
|
87 |
+
protected function _updateActions() {
|
88 |
+
$actionColumn = $this->_columns['action'];
|
89 |
+
$actions = $actionColumn->getActions();
|
90 |
+
$newBaseUrl = '*/sales_order/view' . '/rel/' . true; // We add the /rel/true param to flag the referring
|
91 |
+
|
92 |
+
$actions[0]['url']['base'] = $newBaseUrl;
|
93 |
+
$actionColumn->setActions($actions);
|
94 |
+
|
95 |
+
return $this;
|
96 |
+
}
|
97 |
+
|
98 |
+
/**
|
99 |
+
* Empty this extended method in order to remove mass action block
|
100 |
+
* which usually enables options that are of no use in the current grid
|
101 |
+
*
|
102 |
+
* @return Soon_StockReleaser_Block_Adminhtml_Sales_Order_Canceled_Grid
|
103 |
+
*/
|
104 |
+
protected function _prepareMassaction() {
|
105 |
+
return $this;
|
106 |
+
}
|
107 |
+
|
108 |
+
|
109 |
+
/**
|
110 |
+
* Retrieve row to view order.
|
111 |
+
*
|
112 |
+
* @return mixed string|bool
|
113 |
+
*/
|
114 |
+
public function getRowUrl($row)
|
115 |
+
{
|
116 |
+
if (Mage::getSingleton('admin/session')->isAllowed('sales/order/actions/view')) {
|
117 |
+
return $this->getUrl('*/sales_order/view', array('order_id' => $row->getId(), 'rel' => true));
|
118 |
+
}
|
119 |
+
return false;
|
120 |
+
}
|
121 |
+
|
122 |
+
}
|
app/code/community/Soon/StockReleaser/Block/Adminhtml/System/Config/Form.php
ADDED
@@ -0,0 +1,249 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Agence Soon
|
5 |
+
*
|
6 |
+
* @category Soon
|
7 |
+
* @package Soon_StockReleaser
|
8 |
+
* @copyright Copyright (c) 2011 Agence Soon. (http://www.agence-soon.fr)
|
9 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
10 |
+
* @author Hervé Guétin
|
11 |
+
*
|
12 |
+
* Inspired by Sharpdot_SharpPaymentsByCustomerGroup
|
13 |
+
*
|
14 |
+
*/
|
15 |
+
class Soon_StockReleaser_Block_Adminhtml_System_Config_Form extends Mage_Adminhtml_Block_System_Config_Form {
|
16 |
+
|
17 |
+
/**
|
18 |
+
* Init fieldset fields
|
19 |
+
*
|
20 |
+
* @param Varien_Data_Form_Element_Fieldset $fieldset
|
21 |
+
* @param Varien_Simplexml_Element $group
|
22 |
+
* @param Varien_Simplexml_Element $section
|
23 |
+
* @param string $fieldPrefix
|
24 |
+
* @param string $labelPrefix
|
25 |
+
* @return Soon_StockReleaser_Block_Adminhtml_System_Config_Form
|
26 |
+
*/
|
27 |
+
public function initFields($fieldset, $group, $section, $fieldPrefix='', $labelPrefix='') {
|
28 |
+
if (!$group->is('use_custom_form', 1)) {
|
29 |
+
return parent::initFields($fieldset, $group, $section, $fieldPrefix = '', $labelPrefix = '');
|
30 |
+
}
|
31 |
+
|
32 |
+
if (!$this->_configDataObject) {
|
33 |
+
$this->_initObjects();
|
34 |
+
}
|
35 |
+
|
36 |
+
// Extends for config data
|
37 |
+
$configDataAdditionalGroups = array();
|
38 |
+
|
39 |
+
$paymentMethods = Mage::helper('payment')->getPaymentMethods();
|
40 |
+
|
41 |
+
|
42 |
+
$xmlString = "<config><fields>";
|
43 |
+
$sort_order = 0;
|
44 |
+
|
45 |
+
foreach ($paymentMethods as $code => $paymentMethod) {
|
46 |
+
|
47 |
+
if (!isset($paymentMethod['active']) || $paymentMethod['active'] == 0) {
|
48 |
+
continue;
|
49 |
+
}
|
50 |
+
++$sort_order;
|
51 |
+
$xmlString .= '
|
52 |
+
<' . $code . ' translate="label">
|
53 |
+
<label>' . $paymentMethod['title'] . '</label>
|
54 |
+
<frontend_type>text</frontend_type>
|
55 |
+
<sort_order>' . $sort_order . '</sort_order>
|
56 |
+
<validate>validate-number</validate>
|
57 |
+
<show_in_default>1</show_in_default>
|
58 |
+
<show_in_website>1</show_in_website>
|
59 |
+
<show_in_store>1</show_in_store>
|
60 |
+
</' . $code . '>';
|
61 |
+
|
62 |
+
++$sort_order;
|
63 |
+
|
64 |
+
$xmlString .= '
|
65 |
+
<' . $code . '-unit translate="label">
|
66 |
+
<frontend_type>select</frontend_type>
|
67 |
+
<source_model>stockreleaser/system_config_source_unit</source_model>
|
68 |
+
<sort_order>' . $sort_order . '</sort_order>
|
69 |
+
<show_in_default>1</show_in_default>
|
70 |
+
<show_in_website>1</show_in_website>
|
71 |
+
<show_in_store>1</show_in_store>
|
72 |
+
</' . $code . '-unit>';
|
73 |
+
}
|
74 |
+
$xmlString .= "</fields></config>";
|
75 |
+
|
76 |
+
$element = new Mage_Core_Model_Config_Base();
|
77 |
+
$element->loadString($xmlString);
|
78 |
+
|
79 |
+
|
80 |
+
foreach ($element->getNode('fields') as $elements) {
|
81 |
+
|
82 |
+
$elements = (array) $elements;
|
83 |
+
// sort either by sort_order or by child node values bypassing the sort_order
|
84 |
+
if ($group->sort_fields && $group->sort_fields->by) {
|
85 |
+
$fieldset->setSortElementsByAttribute((string) $group->sort_fields->by, ($group->sort_fields->direction_desc ? SORT_DESC : SORT_ASC)
|
86 |
+
);
|
87 |
+
} else {
|
88 |
+
usort($elements, array($this, '_sortForm'));
|
89 |
+
}
|
90 |
+
|
91 |
+
foreach ($elements as $e) {
|
92 |
+
if (!$this->_canShowField($e)) {
|
93 |
+
continue;
|
94 |
+
}
|
95 |
+
|
96 |
+
/**
|
97 |
+
* Look for custom defined field path
|
98 |
+
*/
|
99 |
+
$path = (string) $e->config_path;
|
100 |
+
if (empty($path)) {
|
101 |
+
$path = $section->getName() . '/' . $group->getName() . '/' . $fieldPrefix . $e->getName();
|
102 |
+
} elseif (strrpos($path, '/') > 0) {
|
103 |
+
// Extend config data with new section group
|
104 |
+
$groupPath = substr($path, 0, strrpos($path, '/'));
|
105 |
+
if (!isset($configDataAdditionalGroups[$groupPath])) {
|
106 |
+
$this->_configData = $this->_configDataObject->extendConfig(
|
107 |
+
$groupPath, false, $this->_configData
|
108 |
+
);
|
109 |
+
$configDataAdditionalGroups[$groupPath] = true;
|
110 |
+
}
|
111 |
+
}
|
112 |
+
|
113 |
+
$id = $section->getName() . '_' . $group->getName() . '_' . $fieldPrefix . $e->getName();
|
114 |
+
|
115 |
+
if (isset($this->_configData[$path])) {
|
116 |
+
$data = $this->_configData[$path];
|
117 |
+
$inherit = false;
|
118 |
+
} else {
|
119 |
+
$data = $this->_configRoot->descend($path);
|
120 |
+
$inherit = true;
|
121 |
+
}
|
122 |
+
if ($e->frontend_model) {
|
123 |
+
$fieldRenderer = Mage::getBlockSingleton((string) $e->frontend_model);
|
124 |
+
} else {
|
125 |
+
$fieldRenderer = $this->_defaultFieldRenderer;
|
126 |
+
}
|
127 |
+
|
128 |
+
$fieldRenderer->setForm($this);
|
129 |
+
$fieldRenderer->setConfigData($this->_configData);
|
130 |
+
|
131 |
+
$helperName = $this->_configFields->getAttributeModule($section, $group, $e);
|
132 |
+
$fieldType = (string) $e->frontend_type ? (string) $e->frontend_type : 'text';
|
133 |
+
$name = 'groups[' . $group->getName() . '][fields][' . $fieldPrefix . $e->getName() . '][value]';
|
134 |
+
$label = Mage::helper($helperName)->__($labelPrefix) . ' ' . Mage::helper($helperName)->__((string) $e->label);
|
135 |
+
$hint = (string) $e->hint ? Mage::helper($helperName)->__((string) $e->hint) : '';
|
136 |
+
|
137 |
+
if ($e->backend_model) {
|
138 |
+
$model = Mage::getModel((string) $e->backend_model);
|
139 |
+
if (!$model instanceof Mage_Core_Model_Config_Data) {
|
140 |
+
Mage::throwException('Invalid config field backend model: ' . (string) $e->backend_model);
|
141 |
+
}
|
142 |
+
$model->setPath($path)
|
143 |
+
->setValue($data)
|
144 |
+
->setWebsite($this->getWebsiteCode())
|
145 |
+
->setStore($this->getStoreCode())
|
146 |
+
->afterLoad();
|
147 |
+
$data = $model->getValue();
|
148 |
+
}
|
149 |
+
|
150 |
+
$comment = $this->_prepareFieldComment($e, $helperName, $data);
|
151 |
+
$tooltip = $this->_prepareFieldTooltip($e, $helperName);
|
152 |
+
|
153 |
+
if ($e->depends) {
|
154 |
+
foreach ($e->depends->children() as $dependent) {
|
155 |
+
$dependentId = $section->getName()
|
156 |
+
. '_' . $group->getName()
|
157 |
+
. '_' . $fieldPrefix
|
158 |
+
. $dependent->getName();
|
159 |
+
$shouldBeAddedDependence = true;
|
160 |
+
$dependentValue = (string) $dependent;
|
161 |
+
$dependentFieldName = $fieldPrefix . $dependent->getName();
|
162 |
+
$dependentField = $group->fields->$dependentFieldName;
|
163 |
+
/*
|
164 |
+
* If dependent field can't be shown in current scope and real dependent config value
|
165 |
+
* is not equal to preferred one, then hide dependence fields by adding dependence
|
166 |
+
* based on not shown field (not rendered field)
|
167 |
+
*/
|
168 |
+
if (!$this->_canShowField($dependentField)) {
|
169 |
+
$dependentFullPath = $section->getName()
|
170 |
+
. '/' . $group->getName()
|
171 |
+
. '/' . $fieldPrefix
|
172 |
+
. $dependent->getName();
|
173 |
+
$shouldBeAddedDependence = $dependentValue != Mage::getStoreConfig(
|
174 |
+
$dependentFullPath, $this->getStoreCode()
|
175 |
+
);
|
176 |
+
}
|
177 |
+
if ($shouldBeAddedDependence) {
|
178 |
+
$this->_getDependence()
|
179 |
+
->addFieldMap($id, $id)
|
180 |
+
->addFieldMap($dependentId, $dependentId)
|
181 |
+
->addFieldDependence($id, $dependentId, $dependentValue);
|
182 |
+
}
|
183 |
+
}
|
184 |
+
}
|
185 |
+
|
186 |
+
$field = $fieldset->addField($id, $fieldType, array(
|
187 |
+
'name' => $name,
|
188 |
+
'label' => $label,
|
189 |
+
'comment' => $comment,
|
190 |
+
'tooltip' => $tooltip,
|
191 |
+
'hint' => $hint,
|
192 |
+
'value' => $data,
|
193 |
+
'inherit' => $inherit,
|
194 |
+
'class' => $e->frontend_class,
|
195 |
+
'field_config' => $e,
|
196 |
+
'scope' => $this->getScope(),
|
197 |
+
'scope_id' => $this->getScopeId(),
|
198 |
+
'scope_label' => $this->getScopeLabel($e),
|
199 |
+
'can_use_default_value' => $this->canUseDefaultValue((int) $e->show_in_default),
|
200 |
+
'can_use_website_value' => $this->canUseWebsiteValue((int) $e->show_in_website),
|
201 |
+
));
|
202 |
+
$this->_prepareFieldOriginalData($field, $e);
|
203 |
+
|
204 |
+
if (isset($e->validate)) {
|
205 |
+
$field->addClass($e->validate);
|
206 |
+
}
|
207 |
+
|
208 |
+
if (isset($e->frontend_type)
|
209 |
+
&& 'multiselect' === (string) $e->frontend_type
|
210 |
+
&& isset($e->can_be_empty)
|
211 |
+
) {
|
212 |
+
$field->setCanBeEmpty(true);
|
213 |
+
}
|
214 |
+
|
215 |
+
$field->setRenderer($fieldRenderer);
|
216 |
+
|
217 |
+
if ($e->source_model) {
|
218 |
+
// determine callback for the source model
|
219 |
+
$factoryName = (string) $e->source_model;
|
220 |
+
$method = false;
|
221 |
+
if (preg_match('/^([^:]+?)::([^:]+?)$/', $factoryName, $matches)) {
|
222 |
+
array_shift($matches);
|
223 |
+
list($factoryName, $method) = array_values($matches);
|
224 |
+
}
|
225 |
+
|
226 |
+
$sourceModel = Mage::getSingleton($factoryName);
|
227 |
+
if ($sourceModel instanceof Varien_Object) {
|
228 |
+
$sourceModel->setPath($path);
|
229 |
+
}
|
230 |
+
if ($method) {
|
231 |
+
if ($fieldType == 'multiselect') {
|
232 |
+
$optionArray = $sourceModel->$method();
|
233 |
+
} else {
|
234 |
+
$optionArray = array();
|
235 |
+
foreach ($sourceModel->$method() as $value => $label) {
|
236 |
+
$optionArray[] = array('label' => $label, 'value' => $value);
|
237 |
+
}
|
238 |
+
}
|
239 |
+
} else {
|
240 |
+
$optionArray = $sourceModel->toOptionArray($fieldType == 'multiselect');
|
241 |
+
}
|
242 |
+
$field->setValues($optionArray);
|
243 |
+
}
|
244 |
+
}
|
245 |
+
}
|
246 |
+
return $this;
|
247 |
+
}
|
248 |
+
|
249 |
+
}
|
app/code/community/Soon/StockReleaser/Helper/Data.php
ADDED
@@ -0,0 +1,14 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Agence Soon
|
5 |
+
*
|
6 |
+
* @category Soon
|
7 |
+
* @package Soon_StockReleaser
|
8 |
+
* @copyright Copyright (c) 2011 Agence Soon. (http://www.agence-soon.fr)
|
9 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
10 |
+
* @author Hervé Guétin
|
11 |
+
*/
|
12 |
+
class Soon_StockReleaser_Helper_Data extends Mage_Core_Helper_Abstract {
|
13 |
+
|
14 |
+
}
|
app/code/community/Soon/StockReleaser/Model/Cancel.php
ADDED
@@ -0,0 +1,123 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Agence Soon
|
5 |
+
*
|
6 |
+
* @category Soon
|
7 |
+
* @package Soon_StockReleaser
|
8 |
+
* @copyright Copyright (c) 2011 Agence Soon. (http://www.agence-soon.fr)
|
9 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
10 |
+
* @author Hervé Guétin
|
11 |
+
*/
|
12 |
+
class Soon_StockReleaser_Model_Cancel extends Mage_Core_Model_Abstract {
|
13 |
+
const ORDER_STATUSES_CONFIG = 'stockreleaser/settings/order_statuses';
|
14 |
+
|
15 |
+
public function _construct() {
|
16 |
+
$this->_init('stockreleaser/cancel');
|
17 |
+
}
|
18 |
+
|
19 |
+
/**
|
20 |
+
* Save cancellation date of order
|
21 |
+
*
|
22 |
+
* @param Mage_Sales_Model_Order $order
|
23 |
+
* @return Soon_StockReleaser_Model_Cancel
|
24 |
+
*/
|
25 |
+
public function registerCancel($order) {
|
26 |
+
$paymentMethod = $order->getPayment()->getMethod();
|
27 |
+
|
28 |
+
$leadtimeValue = Mage::getStoreConfig('stockreleaser/leadtime/' . $paymentMethod);
|
29 |
+
|
30 |
+
if ($leadtimeValue != '') { //Only continue if leadtime value is set.
|
31 |
+
$leadtime = $leadtimeValue * $this->_getLeadtimeMultiplier(Mage::getStoreConfig('stockreleaser/leadtime/' . $paymentMethod . '-unit'));
|
32 |
+
$autoCancelDate = date("Y-m-d H:i:s", strtotime($order->getCreatedAt()) + $leadtime);
|
33 |
+
|
34 |
+
$data = array(
|
35 |
+
'order_id' => $order->getId(),
|
36 |
+
'autocancel_date' => $autoCancelDate,
|
37 |
+
);
|
38 |
+
|
39 |
+
$this->setData($data);
|
40 |
+
$this->save();
|
41 |
+
}
|
42 |
+
|
43 |
+
return $this;
|
44 |
+
}
|
45 |
+
|
46 |
+
/**
|
47 |
+
* Process order cancellation
|
48 |
+
*
|
49 |
+
* @return Soon_StockReleaser_Model_Cancel
|
50 |
+
*/
|
51 |
+
public function processCancel() {
|
52 |
+
|
53 |
+
$orders = Mage::getModel('sales/order')
|
54 |
+
->getCollection()
|
55 |
+
->addAttributeToFilter('status', array('in' => $this->_getOrderStatuses()));
|
56 |
+
|
57 |
+
foreach ($orders as $order) {
|
58 |
+
$ordersIds[] = $order->getId();
|
59 |
+
}
|
60 |
+
|
61 |
+
$ordersToCancel = $this->getResourceCollection()
|
62 |
+
->addFieldToFilter('order_id', array('in' => $ordersIds))
|
63 |
+
->addFieldToFilter('autocancel_date', array('lt' => now()))
|
64 |
+
->addIsNotCanceledFilter();
|
65 |
+
|
66 |
+
foreach ($ordersToCancel as $orderToCancel) {
|
67 |
+
$order = Mage::getModel('sales/order')->load($orderToCancel->getOrderId());
|
68 |
+
$order->cancel()
|
69 |
+
->save();
|
70 |
+
|
71 |
+
$orderComment = Mage::helper('stockreleaser')->__('This order has been automatically cancelled by the "Soon_StockReleaser" module.');
|
72 |
+
$order->setStatus(Mage_Sales_Model_Order::STATE_CANCELED)
|
73 |
+
->addStatusHistoryComment($orderComment)
|
74 |
+
->save();
|
75 |
+
|
76 |
+
$orderToCancel->setAutocancelStatus(1)->save();
|
77 |
+
}
|
78 |
+
|
79 |
+
return $this;
|
80 |
+
}
|
81 |
+
|
82 |
+
/**
|
83 |
+
* Delete outdated orders to automatically cancel
|
84 |
+
*
|
85 |
+
* Those are the ones that are not automatically canceled yet but completed.
|
86 |
+
*
|
87 |
+
* @return Soon_StockReleaser_Model_Cancel
|
88 |
+
*/
|
89 |
+
public function cleanCompletedOrders() {
|
90 |
+
$collection = $this->getResourceCollection()->getCompletedOrders();
|
91 |
+
$collection->walk('delete');
|
92 |
+
return $this;
|
93 |
+
}
|
94 |
+
|
95 |
+
/**
|
96 |
+
* Returns multiplier for seconds based on unit used in config
|
97 |
+
*
|
98 |
+
* @param string $unit
|
99 |
+
* @return int
|
100 |
+
*/
|
101 |
+
protected function _getLeadtimeMultiplier($unit) {
|
102 |
+
$leadtimeMultipliers = array(
|
103 |
+
'min' => 60,
|
104 |
+
'hour' => 3600,
|
105 |
+
'day' => 86400
|
106 |
+
);
|
107 |
+
|
108 |
+
return (int) $leadtimeMultipliers[$unit];
|
109 |
+
}
|
110 |
+
|
111 |
+
/**
|
112 |
+
* Retrieve array of order statuses that must be automatically cancelled
|
113 |
+
*
|
114 |
+
* @return array
|
115 |
+
*/
|
116 |
+
protected function _getOrderStatuses() {
|
117 |
+
$orderStatusesConfig = Mage::getStoreConfig(self::ORDER_STATUSES_CONFIG);
|
118 |
+
$orderStatuses = explode(',', $orderStatusesConfig);
|
119 |
+
|
120 |
+
return $orderStatuses;
|
121 |
+
}
|
122 |
+
|
123 |
+
}
|
app/code/community/Soon/StockReleaser/Model/Mysql4/Cancel.php
ADDED
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Agence Soon
|
5 |
+
*
|
6 |
+
* @category Soon
|
7 |
+
* @package Soon_StockReleaser
|
8 |
+
* @copyright Copyright (c) 2011 Agence Soon. (http://www.agence-soon.fr)
|
9 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
10 |
+
* @author Hervé Guétin (herve.guetin@gmail.com)
|
11 |
+
*/
|
12 |
+
class Soon_StockReleaser_Model_Mysql4_Cancel extends Mage_Core_Model_Mysql4_Abstract {
|
13 |
+
|
14 |
+
public function _construct() {
|
15 |
+
$this->_init('stockreleaser/cancel', 'id');
|
16 |
+
}
|
17 |
+
|
18 |
+
}
|
app/code/community/Soon/StockReleaser/Model/Mysql4/Cancel/Collection.php
ADDED
@@ -0,0 +1,52 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Agence Soon
|
5 |
+
*
|
6 |
+
* @category Soon
|
7 |
+
* @package Soon_StockReleaser
|
8 |
+
* @copyright Copyright (c) 2011 Agence Soon. (http://www.agence-soon.fr)
|
9 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
10 |
+
* @author Hervé Guétin
|
11 |
+
*/
|
12 |
+
class Soon_StockReleaser_Model_Mysql4_Cancel_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract {
|
13 |
+
|
14 |
+
public function _construct() {
|
15 |
+
$this->_init('stockreleaser/cancel');
|
16 |
+
}
|
17 |
+
|
18 |
+
/**
|
19 |
+
* Filter collection with orders that have been automatically canceled
|
20 |
+
*
|
21 |
+
* @return Soon_StockReleaser_Model_Mysql4_Cancel_Collection
|
22 |
+
*/
|
23 |
+
public function addIsCanceledFilter() {
|
24 |
+
$this->addFieldToFilter('autocancel_status', 1);
|
25 |
+
return $this;
|
26 |
+
}
|
27 |
+
|
28 |
+
/**
|
29 |
+
* Filter collection with orders that have not been canceled yet
|
30 |
+
*
|
31 |
+
* @return Soon_StockReleaser_Model_Mysql4_Cancel_Collection
|
32 |
+
*/
|
33 |
+
public function addIsNotCanceledFilter() {
|
34 |
+
$this->addFieldToFilter('autocancel_status', 0);
|
35 |
+
return $this;
|
36 |
+
}
|
37 |
+
|
38 |
+
/**
|
39 |
+
* Retrieve collection of orders that have not been automatically canceled
|
40 |
+
* but that are completed
|
41 |
+
*
|
42 |
+
* @return Soon_StockReleaser_Model_Mysql4_Cancel_Collection
|
43 |
+
*/
|
44 |
+
public function getCompletedOrders() {
|
45 |
+
$this->addIsNotCanceledFilter()
|
46 |
+
->getSelect()
|
47 |
+
->join(array('order_table' => $this->getTable('sales/order')), 'main_table.order_id = order_table.entity_id');
|
48 |
+
$this->addFieldToFilter('state', Mage_Sales_Model_Order::STATE_COMPLETE);
|
49 |
+
return $this;
|
50 |
+
}
|
51 |
+
|
52 |
+
}
|
app/code/community/Soon/StockReleaser/Model/Observer.php
ADDED
@@ -0,0 +1,52 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Agence Soon
|
5 |
+
*
|
6 |
+
* @category Soon
|
7 |
+
* @package Soon_StockReleaser
|
8 |
+
* @copyright Copyright (c) 2011 Agence Soon. (http://www.agence-soon.fr)
|
9 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
10 |
+
* @author Hervé Guétin
|
11 |
+
*/
|
12 |
+
class Soon_StockReleaser_Model_Observer extends Mage_Core_Model_Abstract {
|
13 |
+
|
14 |
+
/**
|
15 |
+
* Retrieve order object from observer and register cancellation date
|
16 |
+
*
|
17 |
+
* @param Varien_Event_Observer $observer
|
18 |
+
* @return Soon_StockReleaser_Model_Observer
|
19 |
+
*/
|
20 |
+
public function setAutoCancelData($observer) {
|
21 |
+
$order = $observer->getEvent()->getOrder();
|
22 |
+
Mage::getModel('stockreleaser/cancel')->registerCancel($order);
|
23 |
+
return $this;
|
24 |
+
}
|
25 |
+
|
26 |
+
/**
|
27 |
+
* Update "Back" button on order view page to make it link to
|
28 |
+
* stockreleaser_adminhtml_sales_order_canceled_grid
|
29 |
+
* instead of core Orders grid.
|
30 |
+
*
|
31 |
+
* @return Soon_StockReleaser_Model_Observer
|
32 |
+
*/
|
33 |
+
public function updateOrderViewGetBackButton() {
|
34 |
+
if (Mage::app()->getRequest()->getParam('rel')) { // If we come from the canceled orders grid, there is a 'rel' param
|
35 |
+
$layout = Mage::app()->getLayout();
|
36 |
+
$buttonsBlock = $layout->getBlock('sales_order_edit');
|
37 |
+
|
38 |
+
$newUrl = Mage::helper('adminhtml')->getUrl('adminhtml/sales_order_canceled/');
|
39 |
+
|
40 |
+
$buttonData = array(
|
41 |
+
'label' => Mage::helper('adminhtml')->__('Back'),
|
42 |
+
'onclick' => 'setLocation(\'' . $newUrl . '\')',
|
43 |
+
'class' => 'back',
|
44 |
+
);
|
45 |
+
|
46 |
+
$buttonsBlock->updateButton('back', null, $buttonData);
|
47 |
+
}
|
48 |
+
|
49 |
+
return $this;
|
50 |
+
}
|
51 |
+
|
52 |
+
}
|
app/code/community/Soon/StockReleaser/Model/System/Config/Source/Order/Status.php
ADDED
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Agence Soon
|
5 |
+
*
|
6 |
+
* @category Soon
|
7 |
+
* @package Soon_StockReleaser
|
8 |
+
* @copyright Copyright (c) 2011 Agence Soon. (http://www.agence-soon.fr)
|
9 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
10 |
+
* @author Hervé Guétin
|
11 |
+
*/
|
12 |
+
class Soon_StockReleaser_Model_System_Config_Source_Order_Status extends Mage_Adminhtml_Model_System_Config_Source_Order_Status {
|
13 |
+
|
14 |
+
/**
|
15 |
+
* Set to null to enable all possible order statuses
|
16 |
+
*
|
17 |
+
* @var null
|
18 |
+
*/
|
19 |
+
protected $_stateStatuses = null;
|
20 |
+
|
21 |
+
}
|
app/code/community/Soon/StockReleaser/Model/System/Config/Source/Unit.php
ADDED
@@ -0,0 +1,28 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Agence Soon
|
5 |
+
*
|
6 |
+
* @category Soon
|
7 |
+
* @package Soon_StockReleaser
|
8 |
+
* @copyright Copyright (c) 2011 Agence Soon. (http://www.agence-soon.fr)
|
9 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
10 |
+
* @author Hervé Guétin
|
11 |
+
*
|
12 |
+
*/
|
13 |
+
class Soon_StockReleaser_Model_System_Config_Source_Unit {
|
14 |
+
|
15 |
+
/**
|
16 |
+
* Options getter
|
17 |
+
*
|
18 |
+
* @return array
|
19 |
+
*/
|
20 |
+
public function toOptionArray() {
|
21 |
+
return array(
|
22 |
+
array('value' => 'min', 'label' => Mage::helper('stockreleaser')->__('Minutes')),
|
23 |
+
array('value' => 'hour', 'label' => Mage::helper('stockreleaser')->__('Hours')),
|
24 |
+
array('value' => 'day', 'label' => Mage::helper('stockreleaser')->__('Days')),
|
25 |
+
);
|
26 |
+
}
|
27 |
+
|
28 |
+
}
|
app/code/community/Soon/StockReleaser/controllers/Adminhtml/Sales/Order/CanceledController.php
ADDED
@@ -0,0 +1,50 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Agence Soon
|
5 |
+
*
|
6 |
+
* @category Soon
|
7 |
+
* @package Soon_StockReleaser
|
8 |
+
* @copyright Copyright (c) 2011 Agence Soon. (http://www.agence-soon.fr)
|
9 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
10 |
+
* @author Hervé Guétin
|
11 |
+
*/
|
12 |
+
require_once 'Mage/Adminhtml/controllers/Sales/OrderController.php';
|
13 |
+
|
14 |
+
class Soon_StockReleaser_Adminhtml_Sales_Order_CanceledController extends Mage_Adminhtml_Sales_OrderController {
|
15 |
+
|
16 |
+
/**
|
17 |
+
* Orders grid
|
18 |
+
*
|
19 |
+
* @return void
|
20 |
+
*/
|
21 |
+
public function indexAction() {
|
22 |
+
$this->_title($this->__('Sales'))->_title($this->__('Automatically Canceled Orders'));
|
23 |
+
|
24 |
+
$this->_initAction()
|
25 |
+
->renderLayout();
|
26 |
+
}
|
27 |
+
|
28 |
+
/**
|
29 |
+
* Export order grid to CSV format
|
30 |
+
*
|
31 |
+
* @return void
|
32 |
+
*/
|
33 |
+
public function exportCsvAction() {
|
34 |
+
$fileName = 'canceled_orders.csv';
|
35 |
+
$grid = $this->getLayout()->createBlock('stockreleaser/adminhtml_sales_order_canceled_grid');
|
36 |
+
$this->_prepareDownloadResponse($fileName, $grid->getCsvFile());
|
37 |
+
}
|
38 |
+
|
39 |
+
/**
|
40 |
+
* Export order grid to Excel XML format
|
41 |
+
*
|
42 |
+
* @return void
|
43 |
+
*/
|
44 |
+
public function exportExcelAction() {
|
45 |
+
$fileName = 'canceled_orders.xml';
|
46 |
+
$grid = $this->getLayout()->createBlock('stockreleaser/adminhtml_sales_order_canceled_grid');
|
47 |
+
$this->_prepareDownloadResponse($fileName, $grid->getExcelFile($fileName));
|
48 |
+
}
|
49 |
+
|
50 |
+
}
|
app/code/community/Soon/StockReleaser/etc/config.xml
ADDED
@@ -0,0 +1,176 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<config>
|
3 |
+
<modules>
|
4 |
+
<Soon_StockReleaser>
|
5 |
+
<version>1.0.0</version>
|
6 |
+
</Soon_StockReleaser>
|
7 |
+
</modules>
|
8 |
+
|
9 |
+
<frontend>
|
10 |
+
<translate>
|
11 |
+
<modules>
|
12 |
+
<Soon_StockReleaser>
|
13 |
+
<files>
|
14 |
+
<default>Soon_StockReleaser.csv</default>
|
15 |
+
</files>
|
16 |
+
</Soon_StockReleaser>
|
17 |
+
</modules>
|
18 |
+
</translate>
|
19 |
+
</frontend>
|
20 |
+
|
21 |
+
<admin>
|
22 |
+
<routers>
|
23 |
+
<adminhtml>
|
24 |
+
<args>
|
25 |
+
<modules>
|
26 |
+
<stockreleaser before="Mage_Adminhtml">Soon_StockReleaser_Adminhtml</stockreleaser>
|
27 |
+
</modules>
|
28 |
+
</args>
|
29 |
+
</adminhtml>
|
30 |
+
</routers>
|
31 |
+
</admin>
|
32 |
+
|
33 |
+
<adminhtml>
|
34 |
+
<events>
|
35 |
+
<controller_action_layout_render_before_adminhtml_sales_order_view>
|
36 |
+
<observers>
|
37 |
+
<update_order_view_get_back_button>
|
38 |
+
<type>singleton</type>
|
39 |
+
<class>stockreleaser/observer</class>
|
40 |
+
<method>updateOrderViewGetBackButton</method>
|
41 |
+
</update_order_view_get_back_button>
|
42 |
+
</observers>
|
43 |
+
</controller_action_layout_render_before_adminhtml_sales_order_view>
|
44 |
+
</events>
|
45 |
+
<layout>
|
46 |
+
<updates>
|
47 |
+
<stockreleaser>
|
48 |
+
<file>stockreleaser.xml</file>
|
49 |
+
</stockreleaser>
|
50 |
+
</updates>
|
51 |
+
</layout>
|
52 |
+
<translate>
|
53 |
+
<modules>
|
54 |
+
<Soon_StockReleaser>
|
55 |
+
<files>
|
56 |
+
<default>Soon_StockReleaser.csv</default>
|
57 |
+
</files>
|
58 |
+
</Soon_StockReleaser>
|
59 |
+
</modules>
|
60 |
+
</translate>
|
61 |
+
<menu>
|
62 |
+
<sales>
|
63 |
+
<children>
|
64 |
+
<stockreleaser_canceled_orders translate="title" module="stockreleaser">
|
65 |
+
<title>Automatically Canceled Orders</title>
|
66 |
+
<action>adminhtml/sales_order_canceled</action>
|
67 |
+
<sort_order>15</sort_order>
|
68 |
+
</stockreleaser_canceled_orders>
|
69 |
+
</children>
|
70 |
+
</sales>
|
71 |
+
</menu>
|
72 |
+
<acl>
|
73 |
+
<resources>
|
74 |
+
<all>
|
75 |
+
<title>Allow Everything</title>
|
76 |
+
</all>
|
77 |
+
<admin>
|
78 |
+
<children>
|
79 |
+
<sales>
|
80 |
+
<children>
|
81 |
+
<stockreleaser_canceled_orders translate="title">
|
82 |
+
<title>Automatically Canceled Orders</title>
|
83 |
+
</stockreleaser_canceled_orders>
|
84 |
+
</children>
|
85 |
+
</sales>
|
86 |
+
<system>
|
87 |
+
<children>
|
88 |
+
<config>
|
89 |
+
<children>
|
90 |
+
<stockreleaser translate="title" module="stockreleaser">
|
91 |
+
<title>Stock Releaser</title>
|
92 |
+
</stockreleaser>
|
93 |
+
</children>
|
94 |
+
</config>
|
95 |
+
</children>
|
96 |
+
</system>
|
97 |
+
</children>
|
98 |
+
</admin>
|
99 |
+
</resources>
|
100 |
+
</acl>
|
101 |
+
</adminhtml>
|
102 |
+
|
103 |
+
<global>
|
104 |
+
<events>
|
105 |
+
<sales_order_place_after>
|
106 |
+
<observers>
|
107 |
+
<set_autocancel>
|
108 |
+
<type>singleton</type>
|
109 |
+
<class>stockreleaser/observer</class>
|
110 |
+
<method>setAutoCancelData</method>
|
111 |
+
</set_autocancel>
|
112 |
+
</observers>
|
113 |
+
</sales_order_place_after>
|
114 |
+
</events>
|
115 |
+
<blocks>
|
116 |
+
<stockreleaser>
|
117 |
+
<class>Soon_StockReleaser_Block</class>
|
118 |
+
</stockreleaser>
|
119 |
+
</blocks>
|
120 |
+
<helpers>
|
121 |
+
<stockreleaser>
|
122 |
+
<class>Soon_StockReleaser_Helper</class>
|
123 |
+
</stockreleaser>
|
124 |
+
</helpers>
|
125 |
+
<models>
|
126 |
+
<stockreleaser>
|
127 |
+
<class>Soon_StockReleaser_Model</class>
|
128 |
+
<resourceModel>stockreleaser_mysql4</resourceModel>
|
129 |
+
</stockreleaser>
|
130 |
+
<stockreleaser_mysql4>
|
131 |
+
<class>Soon_StockReleaser_Model_Mysql4</class>
|
132 |
+
<entities>
|
133 |
+
<cancel>
|
134 |
+
<table>stockreleaser_cancel</table>
|
135 |
+
</cancel>
|
136 |
+
</entities>
|
137 |
+
</stockreleaser_mysql4>
|
138 |
+
</models>
|
139 |
+
<resources>
|
140 |
+
<stockreleaser_setup>
|
141 |
+
<setup>
|
142 |
+
<module>Soon_StockReleaser</module>
|
143 |
+
</setup>
|
144 |
+
</stockreleaser_setup>
|
145 |
+
</resources>
|
146 |
+
</global>
|
147 |
+
|
148 |
+
<default>
|
149 |
+
<stockreleaser>
|
150 |
+
<settings>
|
151 |
+
<order_statuses>payment_review,pending,pending_payment,pending_paypal</order_statuses>
|
152 |
+
</settings>
|
153 |
+
</stockreleaser>
|
154 |
+
</default>
|
155 |
+
|
156 |
+
<crontab>
|
157 |
+
<jobs>
|
158 |
+
<stockreleaser_cancel>
|
159 |
+
<schedule>
|
160 |
+
<cron_expr>* * * * *</cron_expr>
|
161 |
+
</schedule>
|
162 |
+
<run>
|
163 |
+
<model>stockreleaser/cancel::processCancel</model>
|
164 |
+
</run>
|
165 |
+
</stockreleaser_cancel>
|
166 |
+
<stockreleaser_clean_completed_orders>
|
167 |
+
<schedule>
|
168 |
+
<cron_expr>* * * * *</cron_expr>
|
169 |
+
</schedule>
|
170 |
+
<run>
|
171 |
+
<model>stockreleaser/cancel::cleanCompletedOrders</model>
|
172 |
+
</run>
|
173 |
+
</stockreleaser_clean_completed_orders>
|
174 |
+
</jobs>
|
175 |
+
</crontab>
|
176 |
+
</config>
|
app/code/community/Soon/StockReleaser/etc/system.xml
ADDED
@@ -0,0 +1,63 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<!--
|
3 |
+
/**
|
4 |
+
* Agence Soon
|
5 |
+
*
|
6 |
+
*
|
7 |
+
* @category Soon
|
8 |
+
* @package Soon_StockReleaser
|
9 |
+
* @copyright Copyright (c) 2011 Agence Soon. (http://www.agence-soon.fr)
|
10 |
+
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
|
11 |
+
* @author Hervé Guétin
|
12 |
+
*/
|
13 |
+
-->
|
14 |
+
<config>
|
15 |
+
<sections>
|
16 |
+
<stockreleaser translate="label" module="stockreleaser">
|
17 |
+
<label>Stock Release</label>
|
18 |
+
<tab>soon</tab>
|
19 |
+
<frontend_type>text</frontend_type>
|
20 |
+
<sort_order>1000</sort_order>
|
21 |
+
<show_in_default>1</show_in_default>
|
22 |
+
<show_in_website>1</show_in_website>
|
23 |
+
<show_in_store>1</show_in_store>
|
24 |
+
|
25 |
+
<frontend_model>stockreleaser/adminhtml_system_config_form</frontend_model>
|
26 |
+
|
27 |
+
<groups>
|
28 |
+
<settings translate="label">
|
29 |
+
<label>Settings</label>
|
30 |
+
<frontend_type>text</frontend_type>
|
31 |
+
<sort_order>10</sort_order>
|
32 |
+
<show_in_default>1</show_in_default>
|
33 |
+
<show_in_website>1</show_in_website>
|
34 |
+
<show_in_store>1</show_in_store>
|
35 |
+
<fields>
|
36 |
+
<order_statuses translate="label">
|
37 |
+
<label>Order Statuses</label>
|
38 |
+
<frontend_type>multiselect</frontend_type>
|
39 |
+
<comment>Order statuses that must be automatically cancelled</comment>
|
40 |
+
<sort_order>1</sort_order>
|
41 |
+
<source_model>stockreleaser/system_config_source_order_status</source_model>
|
42 |
+
<show_in_default>1</show_in_default>
|
43 |
+
<show_in_website>1</show_in_website>
|
44 |
+
<show_in_store>1</show_in_store>
|
45 |
+
<can_be_empty>1</can_be_empty>
|
46 |
+
</order_statuses>
|
47 |
+
</fields>
|
48 |
+
</settings>
|
49 |
+
<leadtime>
|
50 |
+
<label>Leadtimes Manager</label>
|
51 |
+
<frontend_type>text</frontend_type>
|
52 |
+
<sort_order>20</sort_order>
|
53 |
+
<show_in_default>1</show_in_default>
|
54 |
+
<show_in_website>1</show_in_website>
|
55 |
+
<show_in_store>1</show_in_store>
|
56 |
+
|
57 |
+
<use_custom_form>1</use_custom_form>
|
58 |
+
|
59 |
+
</leadtime>
|
60 |
+
</groups>
|
61 |
+
</stockreleaser>
|
62 |
+
</sections>
|
63 |
+
</config>
|
app/code/community/Soon/StockReleaser/sql/stockreleaser_setup/mysql4-install-0.1.0.php
ADDED
@@ -0,0 +1,28 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Agence Soon
|
5 |
+
*
|
6 |
+
* @category Soon
|
7 |
+
* @package Soon_StockReleaser
|
8 |
+
* @copyright Copyright (c) 2011 Agence Soon. (http://www.agence-soon.fr)
|
9 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
10 |
+
* @author Hervé Guétin
|
11 |
+
*/
|
12 |
+
$installer = $this;
|
13 |
+
|
14 |
+
$installer->startSetup();
|
15 |
+
|
16 |
+
$installer->run("
|
17 |
+
|
18 |
+
-- DROP TABLE IF EXISTS stockreleaser_cancel;
|
19 |
+
CREATE TABLE stockreleaser_cancel (
|
20 |
+
`id` tinyint(4) unsigned NOT NULL auto_increment,
|
21 |
+
`order_id` text NOT NULL default '',
|
22 |
+
`autocancel_date` datetime,
|
23 |
+
`autocancel_status` tinyint(1) NOT NULL default '0',
|
24 |
+
PRIMARY KEY (`id`)
|
25 |
+
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
26 |
+
");
|
27 |
+
|
28 |
+
$installer->endSetup();
|
app/code/community/Soon/StockReleaser/todo.txt
ADDED
@@ -0,0 +1,19 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
== Reste à faire ==
|
2 |
+
|
3 |
+
Test sur 1.4
|
4 |
+
|
5 |
+
* Documentation
|
6 |
+
- Attention Cron
|
7 |
+
|
8 |
+
|
9 |
+
== Testé sur ===
|
10 |
+
1.6.0.0
|
11 |
+
|
12 |
+
== Fait ==
|
13 |
+
|
14 |
+
25.10.2011 - Traductions restantes
|
15 |
+
25.10.2011 - Nettoyage des commandes terminées
|
16 |
+
25.10.2011 - Revoir en-tête classes pour être conforme aux règles de dev Soon
|
17 |
+
25.10.2011 - Revoir commentaires code pour être conforme aux règles de dev Soon
|
18 |
+
24.10.2011 - Ajout champ annulation sur grid + suppression delete (attention ajout champ "autocancel_status") => Création d'une grille des commandes annulées.
|
19 |
+
19.10.2011 - Config des délais dans system > configuration et mise à jour des modèles / du module en conséquence.
|
app/design/adminhtml/default/default/layout/stockreleaser.xml
ADDED
@@ -0,0 +1,24 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<!--
|
3 |
+
/**
|
4 |
+
* Agence Soon
|
5 |
+
*
|
6 |
+
*
|
7 |
+
* @category adminhtml design
|
8 |
+
* @package default_default
|
9 |
+
* @copyright Copyright (c) 2011 Agence Soon. (http://www.agence-soon.fr)
|
10 |
+
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
|
11 |
+
* @author Hervé Guétin
|
12 |
+
*/
|
13 |
+
-->
|
14 |
+
<layout version="0.1.0">
|
15 |
+
<adminhtml_sales_order_canceled_grid>
|
16 |
+
<update handle="formkey"/>
|
17 |
+
<block type="stockreleaser/adminhtml_sales_order_canceled_grid" name="sales_order_canceled.grid" output="toHtml"></block>
|
18 |
+
</adminhtml_sales_order_canceled_grid>
|
19 |
+
<adminhtml_sales_order_canceled_index>
|
20 |
+
<reference name="content">
|
21 |
+
<block type="stockreleaser/adminhtml_sales_order_canceled" name="sales_order_canceled.grid.container"></block>
|
22 |
+
</reference>
|
23 |
+
</adminhtml_sales_order_canceled_index>
|
24 |
+
</layout>
|
app/etc/modules/Soon_StockReleaser.xml
ADDED
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<config>
|
3 |
+
<modules>
|
4 |
+
<Soon_StockReleaser>
|
5 |
+
<active>true</active>
|
6 |
+
<codePool>community</codePool>
|
7 |
+
</Soon_StockReleaser>
|
8 |
+
</modules>
|
9 |
+
</config>
|
app/locale/fr_FR/Soon_StockReleaser.csv
ADDED
@@ -0,0 +1,24 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
"Automatically Canceled Orders","Commandes annulées automatiquement"
|
2 |
+
"Canceled On","Date d'annulation"
|
3 |
+
"Days","Jours"
|
4 |
+
"Delete Leadtime","Supprimer le délai"
|
5 |
+
"Edit Leadtime '%s'","Editer le délai '%s'"
|
6 |
+
"Hours","Heures"
|
7 |
+
"In minutes","En minutes"
|
8 |
+
"Leadtime","Délai"
|
9 |
+
"Leadtime (in min.)","Délai (en min.)"
|
10 |
+
"Leadtime information","Informations sur ce délai"
|
11 |
+
"Leadtimes Manager","Gestion des délais avant annulation de commande"
|
12 |
+
"New Leadtime","Nouveau délai"
|
13 |
+
"Order Statuses","Statuts des commandes"
|
14 |
+
"Order statuses that must be automatically cancelled","Statuts des commandes devant être automatiquement annulées"
|
15 |
+
"Save Leadtime","Enregistrer le délai"
|
16 |
+
"Stock Release","Libération stocks automatique"
|
17 |
+
"Stock Release Leadtime","Délai avant annulation de la commande"
|
18 |
+
"Stock Release Leadtimes","Libération stocks & annulation commande"
|
19 |
+
"The leadtime has been deleted.","Le délai à bien été supprimé."
|
20 |
+
"The leadtime has been saved.","Le délai a bien été enregistré."
|
21 |
+
"This leadtime no longer exists.","Ce délai n'existe plus."
|
22 |
+
"This order has been automatically cancelled by the ""Soon_StockReleaser"" module.","Annulation automatique par le module ""Soon_StockReleaser""."
|
23 |
+
"This payment method already has a leadtime set.","Ce mode de paiement est déjà associé à un délai de libération des stocks."
|
24 |
+
"Unable to find a leadtime to delete.","Impossible de trouver un délai à supprimer"
|
package.xml
ADDED
@@ -0,0 +1,42 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<package>
|
3 |
+
<name>soonstockreleaser</name>
|
4 |
+
<version>1.0.0</version>
|
5 |
+
<stability>stable</stability>
|
6 |
+
<license uri="http://opensource.org/licenses/AFL-3.0">AFL 3.0</license>
|
7 |
+
<channel>community</channel>
|
8 |
+
<extends/>
|
9 |
+
<summary>This extension allows the automatic cancellation of orders that haven't been paid.
|
10 |
+

|
11 |
+
=====
|
12 |
+

|
13 |
+
Ce module annule automatiquement les commandes non payées.</summary>
|
14 |
+
<description>This extension allows the automatic cancellation of orders that haven't been paid.
|
15 |
+

|
16 |
+
The administrator can chose, for each payment type, the leadtime before the order is cancelled, ie : 15 min for credit cards and 7 days for checks.
|
17 |
+

|
18 |
+
It is also possible to chose which order statuses are to be canceled.
|
19 |
+

|
20 |
+
A grid listing all automatically canceled orders is available in the backend.
|
21 |
+

|
22 |
+
Stock management follows the Magento core workflow.
|
23 |
+

|
24 |
+
=====
|
25 |
+

|
26 |
+
Ce module annule automatiquement les commandes non payées.
|
27 |
+

|
28 |
+
L'administrateur peut choisir, pour chaque mode de paiement, le délai avant annulation, par exemple, 15 min pour les paiement par CB ou 7 jours pour les paiements par chèque.
|
29 |
+

|
30 |
+
Il est aussi possible de choisir quels statuts de commande sont sujets à annulation automatique.
|
31 |
+

|
32 |
+
Une grille listant toutes les commandes automatiquement annulées est disponible depuis le back-office.
|
33 |
+

|
34 |
+
La gestion des stocks suit le workflow core de Magento.</description>
|
35 |
+
<notes>First stable release.</notes>
|
36 |
+
<authors><author><name>Hervé Guétin</name><user>auto-converted</user><email>contact@agence-soon.fr</email></author></authors>
|
37 |
+
<date>2011-12-07</date>
|
38 |
+
<time>11:47:02</time>
|
39 |
+
<contents><target name="magecommunity"><dir name="Soon"><dir name="StockReleaser"><dir name="Block"><dir name="Adminhtml"><dir name="Sales"><dir name="Order"><dir name="Canceled"><file name="Grid.php" hash="2ab54aea2466416f79270c6157f4027b"/></dir><file name="Canceled.php" hash="f3b053eb0ed1b2e90e5590e39a6d438e"/></dir></dir><dir name="System"><dir name="Config"><file name="Form.php" hash="0f7593d7d5cdf600e84ff5534f7be38c"/></dir></dir></dir></dir><dir name="Helper"><file name="Data.php" hash="84acca73a948d547bf9758dd171d380a"/></dir><dir name="Model"><dir name="Mysql4"><dir name="Cancel"><file name="Collection.php" hash="6c20ecd45e02cac81fbbfb40004e4503"/></dir><file name="Cancel.php" hash="fc4a5783d80bf3e1d93758f98031dcc5"/></dir><dir name="System"><dir name="Config"><dir name="Source"><dir name="Order"><file name="Status.php" hash="e41c7f2dea058b1d553c3f23ba1b7e13"/></dir><file name="Unit.php" hash="cbca7c0591fde1b5c9695838360a0f02"/></dir></dir></dir><file name="Cancel.php" hash="17733aaec655bc08ff383885bf71b8d1"/><file name="Observer.php" hash="7f3b8d9b62953e83213a615b9b4377be"/></dir><dir name="controllers"><dir name="Adminhtml"><dir name="Sales"><dir name="Order"><file name="CanceledController.php" hash="21c172dfc466a7ac717888bab8cc5f23"/></dir></dir></dir></dir><dir name="etc"><file name="config.xml" hash="4412d56f316f0037f731287d37310b0b"/><file name="system.xml" hash="5147f906671110bfe8c6d243688ca257"/></dir><dir name="sql"><dir name="stockreleaser_setup"><file name="mysql4-install-0.1.0.php" hash="91d1d03e1958d4a077db39392dc40fa9"/></dir></dir><file name="todo.txt" hash="9fca20a656dd91dd42764020c5531c9b"/></dir></dir></target><target name="magedesign"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="layout"><file name="stockreleaser.xml" hash="cefb4ab4827886c5bb74f9764c955b50"/></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Soon_StockReleaser.xml" hash="e60326b41f8446add982cd7f6ee1f782"/></dir></target><target name="magelocale"><dir name="fr_FR"><file name="Soon_StockReleaser.csv" hash="650762314ddaee6197e8962d5405441f"/></dir></target></contents>
|
40 |
+
<compatible/>
|
41 |
+
<dependencies><required><package><name>soonall</name><channel>community</channel><min>0.1.0</min><max>100.0.0</max></package></required></dependencies>
|
42 |
+
</package>
|