Version Notes
Initial release.
Download this release
Release Info
Developer | Discopylabs |
Extension | DCL_Fulfillment |
Version | 1.0.0 |
Comparing to | |
See all releases |
Version 1.0.0
- app/code/community/DCL/Fulfillment/Block/Adminhtml/Config/Form/Accountnumber.php +17 -0
- app/code/community/DCL/Fulfillment/Block/Adminhtml/Config/Form/Field/Shippingtable.php +46 -0
- app/code/community/DCL/Fulfillment/Block/Adminhtml/Config/Form/Link.php +61 -0
- app/code/community/DCL/Fulfillment/Block/Adminhtml/Config/Form/Readonlyconditionalfield.php +19 -0
- app/code/community/DCL/Fulfillment/Helper/Admin.php +237 -0
- app/code/community/DCL/Fulfillment/Helper/Data.php +7 -0
- app/code/community/DCL/Fulfillment/Model/Acknowledgedorder.php +34 -0
- app/code/community/DCL/Fulfillment/Model/Inventory.php +31 -0
- app/code/community/DCL/Fulfillment/Model/Observer.php +30 -0
- app/code/community/DCL/Fulfillment/Model/Resource/Acknowledgedorder.php +21 -0
- app/code/community/DCL/Fulfillment/Model/Resource/Acknowledgedorder/Collection.php +20 -0
- app/code/community/DCL/Fulfillment/Model/Resource/Inventory.php +20 -0
- app/code/community/DCL/Fulfillment/Model/Resource/Inventory/Collection.php +20 -0
- app/code/community/DCL/Fulfillment/Model/System/Config/Source/Acknowledgestatus.php +51 -0
- app/code/community/DCL/Fulfillment/Model/System/Config/Source/Days.php +46 -0
- app/code/community/DCL/Fulfillment/Model/System/Config/Source/Orderage.php +48 -0
- app/code/community/DCL/Fulfillment/Model/System/Config/Source/Statuslist.php +48 -0
- app/code/community/DCL/Fulfillment/controllers/ApiController.php +446 -0
- app/code/community/DCL/Fulfillment/controllers/RegisterController.php +66 -0
- app/code/community/DCL/Fulfillment/etc/adminhtml.xml +29 -0
- app/code/community/DCL/Fulfillment/etc/config.xml +136 -0
- app/code/community/DCL/Fulfillment/etc/system.xml +251 -0
- app/code/community/DCL/Fulfillment/sql/dcl_fulfillment_setup/install-1.0.0.php +113 -0
- app/design/adminhtml/default/default/layout/dcl_fulfillment.xml +36 -0
- app/design/adminhtml/default/default/template/dcl/array.phtml +155 -0
- app/design/adminhtml/default/default/template/dcl/link_button.phtml +76 -0
- app/etc/modules/DCL_Fulfillment.xml +22 -0
- package.xml +19 -0
- skin/adminhtml/default/default/images/dcl_fulfillment_logo.png +0 -0
app/code/community/DCL/Fulfillment/Block/Adminhtml/Config/Form/Accountnumber.php
ADDED
@@ -0,0 +1,17 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* @author DCL
|
5 |
+
*/
|
6 |
+
|
7 |
+
class DCL_Fulfillment_Block_Adminhtml_Config_Form_Accountnumber extends Mage_Adminhtml_Block_System_Config_Form_Field
|
8 |
+
{
|
9 |
+
protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element) {
|
10 |
+
$this->setElement($element);
|
11 |
+
$element->setDisabled('disabled');
|
12 |
+
$element->setStyle('border: 0; color:#494; background-color:transparent;');
|
13 |
+
return parent::_getElementHtml($element);
|
14 |
+
}
|
15 |
+
}
|
16 |
+
|
17 |
+
?>
|
app/code/community/DCL/Fulfillment/Block/Adminhtml/Config/Form/Field/Shippingtable.php
ADDED
@@ -0,0 +1,46 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* @author DCL
|
5 |
+
*/
|
6 |
+
|
7 |
+
class DCL_Fulfillment_Block_Adminhtml_Config_Form_Field_Shippingtable extends Mage_Adminhtml_Block_System_Config_Form_Field_Array_Abstract
|
8 |
+
{
|
9 |
+
public function __construct() {
|
10 |
+
$this->addColumn('ship_name', array(
|
11 |
+
'label' => Mage::helper('dcl_fulfillment')->__('Magento Shipping Method'),
|
12 |
+
));
|
13 |
+
$this->addColumn('ship_code', array(
|
14 |
+
'label' => Mage::helper('dcl_fulfillment')->__(' '),
|
15 |
+
'style' => 'display:none',
|
16 |
+
));
|
17 |
+
$this->addColumn('dcl_carrier', array(
|
18 |
+
'label' => Mage::helper('dcl_fulfillment')->__('DCL Carrier'),
|
19 |
+
'style' => 'width:140px',
|
20 |
+
));
|
21 |
+
$this->addColumn('dcl_service', array(
|
22 |
+
'label' => Mage::helper('dcl_fulfillment')->__('DCL Service'),
|
23 |
+
'style' => 'width:250px',
|
24 |
+
));
|
25 |
+
$this->_addAfter = false;
|
26 |
+
$this->setTemplate('dcl/array.phtml');
|
27 |
+
|
28 |
+
parent::__construct();
|
29 |
+
}
|
30 |
+
|
31 |
+
protected function _renderCellTemplate($columnName)
|
32 |
+
{
|
33 |
+
if (empty($this->_columns[$columnName])) {
|
34 |
+
throw new Exception('Wrong column name specified.');
|
35 |
+
}
|
36 |
+
|
37 |
+
$column = $this->_columns[$columnName];
|
38 |
+
$inputName = $this->getElement()->getName() . '[#{_id}][' . $columnName . ']';
|
39 |
+
if ($columnName == 'ship_name') {
|
40 |
+
return '<span style="white-space: nowrap;">#{' . $columnName . '}</span><input type="hidden" name="' . $inputName . '" value="#{' . $columnName . '}" ' . ($column['size'] ? 'size="' . $column['size'] . '"' : '') . '/>';
|
41 |
+
}
|
42 |
+
else return parent::_renderCellTemplate($columnName);
|
43 |
+
}
|
44 |
+
}
|
45 |
+
|
46 |
+
?>
|
app/code/community/DCL/Fulfillment/Block/Adminhtml/Config/Form/Link.php
ADDED
@@ -0,0 +1,61 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* @author DCL
|
5 |
+
*/
|
6 |
+
|
7 |
+
class DCL_Fulfillment_Block_Adminhtml_Config_Form_Link extends Mage_Adminhtml_Block_System_Config_Form_Field
|
8 |
+
{
|
9 |
+
/*
|
10 |
+
* Set template
|
11 |
+
*/
|
12 |
+
protected function _construct()
|
13 |
+
{
|
14 |
+
parent::_construct();
|
15 |
+
$this->setTemplate('dcl/link_button.phtml');
|
16 |
+
}
|
17 |
+
|
18 |
+
/**
|
19 |
+
* Return element html
|
20 |
+
*
|
21 |
+
* @param Varien_Data_Form_Element_Abstract $element
|
22 |
+
* @return string
|
23 |
+
*/
|
24 |
+
protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
|
25 |
+
{
|
26 |
+
return $this->_toHtml();
|
27 |
+
}
|
28 |
+
|
29 |
+
/**
|
30 |
+
* Return ajax url for button
|
31 |
+
*
|
32 |
+
* @return string
|
33 |
+
*/
|
34 |
+
public function getAjaxLinkUrl()
|
35 |
+
{
|
36 |
+
//return "/dcl_fulfillment/api?api=setup_store";
|
37 |
+
return "/dcl_fulfillment/register";
|
38 |
+
}
|
39 |
+
|
40 |
+
/**
|
41 |
+
* Generate button html
|
42 |
+
*
|
43 |
+
* @return string
|
44 |
+
*/
|
45 |
+
public function getButtonHtml()
|
46 |
+
{
|
47 |
+
$code = Mage::getSingleton('adminhtml/config_data')->getStore();
|
48 |
+
$store_id = Mage::getModel('core/store')->load($code)->getId();
|
49 |
+
$button = $this->getLayout()->createBlock('adminhtml/widget_button')
|
50 |
+
->setData(array(
|
51 |
+
'id' => 'dcl_fulfillment_link',
|
52 |
+
'label' => (Mage::helper('dcl_fulfillment/admin')->isAccountSetup()? $this->helper('adminhtml')->__('Unlink from eFactory Account'): $this->helper('adminhtml')->__('Link to eFactory Account')),
|
53 |
+
'onclick' => 'javascript:linkToEFactory(document.getElementById(\'dcl_fulfillment_general_efactory_username\').value, document.getElementById(\'dcl_fulfillment_general_efactory_password\').value, document.getElementById(\'dcl_fulfillment_general_account_number\').value,\'' . addslashes(Mage::helper('dcl_fulfillment')->__('Link to eFactory Account')) . '\',\'' . addslashes(Mage::helper('dcl_fulfillment')->__('Unlink from eFactory Account')) . '\',\'' . addslashes(Mage::getBaseUrl( Mage_Core_Model_Store::URL_TYPE_WEB, true)) . '\', ' . $store_id . '); return false;',
|
54 |
+
'style' => 'margin-bottom: 15px'
|
55 |
+
));
|
56 |
+
|
57 |
+
return $button->toHtml();
|
58 |
+
}
|
59 |
+
}
|
60 |
+
|
61 |
+
?>
|
app/code/community/DCL/Fulfillment/Block/Adminhtml/Config/Form/Readonlyconditionalfield.php
ADDED
@@ -0,0 +1,19 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* @author DCL
|
5 |
+
*/
|
6 |
+
|
7 |
+
class DCL_Fulfillment_Block_Adminhtml_Config_Form_Readonlyconditionalfield extends Mage_Adminhtml_Block_System_Config_Form_Field
|
8 |
+
{
|
9 |
+
protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element) {
|
10 |
+
if (Mage::helper('dcl_fulfillment/admin')->isAccountSetup()) {
|
11 |
+
$this->setElement($element);
|
12 |
+
$element->setDisabled('disabled');
|
13 |
+
$element->setStyle('border: 0; color:#494; background-color:transparent;');
|
14 |
+
}
|
15 |
+
return parent::_getElementHtml($element);
|
16 |
+
}
|
17 |
+
}
|
18 |
+
|
19 |
+
?>
|
app/code/community/DCL/Fulfillment/Helper/Admin.php
ADDED
@@ -0,0 +1,237 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* @author DCL
|
5 |
+
*/
|
6 |
+
|
7 |
+
class DCL_Fulfillment_Helper_Admin extends Mage_Core_Helper_Abstract
|
8 |
+
{
|
9 |
+
public function isAccountSetup() {
|
10 |
+
$code = Mage::getSingleton('adminhtml/config_data')->getStore();
|
11 |
+
$store_id = Mage::getModel('core/store')->load($code)->getId();
|
12 |
+
$account = Mage::getStoreConfig('dcl_fulfillment/general/account_number', $store_id);
|
13 |
+
return $account != '';
|
14 |
+
}
|
15 |
+
|
16 |
+
public function setDefaultShippingData() {
|
17 |
+
$methods = Mage::getSingleton('shipping/config')->getActiveCarriers();
|
18 |
+
$shipping = array();
|
19 |
+
|
20 |
+
foreach($methods as $_ccode => $_carrier)
|
21 |
+
{
|
22 |
+
if ($_methods = $_carrier->getAllowedMethods())
|
23 |
+
{
|
24 |
+
if (!$_title = Mage::getStoreConfig("carriers/$_ccode/title")) $_title = $_ccode;
|
25 |
+
foreach ($_methods as $_mcode => $_method)
|
26 |
+
{
|
27 |
+
$dcl_carrier_service = $this->getDefaultDCLCarrier($_ccode .'_'. $_mcode);
|
28 |
+
$shipping[$_ccode .'_'. $_mcode] = array (
|
29 |
+
'ship_name' => $_title . ' - ' . $_method,
|
30 |
+
'ship_code' => $_ccode .'_'. $_mcode,
|
31 |
+
'dcl_carrier' => $dcl_carrier_service[0],
|
32 |
+
'dcl_service' => $dcl_carrier_service[1],
|
33 |
+
);
|
34 |
+
}
|
35 |
+
}
|
36 |
+
}
|
37 |
+
|
38 |
+
// sort before saving?
|
39 |
+
$installer = new Mage_Eav_Model_Entity_Setup('core_setup');
|
40 |
+
$installer->startSetup();
|
41 |
+
|
42 |
+
// Load full default settings
|
43 |
+
// It keeps track also of the shipping method settings that are not currently active
|
44 |
+
$storedArray = unserialize(Mage::getStoreConfig('dcl_fulfillment/shipping/shippingtable_full'));
|
45 |
+
if (is_array($storedArray)) {
|
46 |
+
foreach ($shipping as $key => $value) {
|
47 |
+
// Add missing (now active)
|
48 |
+
if (!array_key_exists ($key, $storedArray)) {
|
49 |
+
$storedArray[$key] = $value;
|
50 |
+
}
|
51 |
+
}
|
52 |
+
}
|
53 |
+
else $storedArray = $shipping;
|
54 |
+
|
55 |
+
// Merge with values just saved (if any)
|
56 |
+
$savedArray = unserialize(Mage::getStoreConfig('dcl_fulfillment/shipping/shippingtable'));
|
57 |
+
if (is_array($savedArray)) {
|
58 |
+
foreach ($savedArray as $key => $value) {
|
59 |
+
// Add missing (now active)
|
60 |
+
if (array_key_exists ($key, $storedArray)) {
|
61 |
+
$storedArray[$key] = $value;
|
62 |
+
}
|
63 |
+
}
|
64 |
+
}
|
65 |
+
|
66 |
+
// Save full updated default config
|
67 |
+
$installer->setConfigData("dcl_fulfillment/shipping/shippingtable_full", serialize($storedArray));
|
68 |
+
|
69 |
+
// remove no more active shipping method
|
70 |
+
foreach ($storedArray as $key => $value) {
|
71 |
+
if (!array_key_exists ($key, $shipping)) {
|
72 |
+
unset($storedArray[$key]);
|
73 |
+
}
|
74 |
+
else {
|
75 |
+
// Update ship name
|
76 |
+
$storedArray[$key]['ship_name'] = $shipping[$key]['ship_name'];
|
77 |
+
}
|
78 |
+
}
|
79 |
+
$installer->setConfigData("dcl_fulfillment/shipping/shippingtable", serialize($storedArray));
|
80 |
+
|
81 |
+
$installer->endSetup();
|
82 |
+
}
|
83 |
+
|
84 |
+
private function getDefaultDCLCarrier($ship_code) {
|
85 |
+
$array = ['',''];
|
86 |
+
|
87 |
+
switch($ship_code) {
|
88 |
+
// USPS default mapping
|
89 |
+
case 'usps_0_FCLE':
|
90 |
+
$array[0] = 'USPS'; $array[1] = 'FIRST CLASS'; break;
|
91 |
+
case 'usps_0_FCL':
|
92 |
+
$array[0] = 'USPS'; $array[1] = 'FIRST CLASS'; break;
|
93 |
+
case 'usps_0_FCP':
|
94 |
+
$array[0] = 'USPS'; $array[1] = 'FIRST CLASS'; break;
|
95 |
+
case 'usps_1':
|
96 |
+
$array[0] = 'USPS'; $array[1] = 'PRIORITY MAIL'; break;
|
97 |
+
case 'usps_3':
|
98 |
+
$array[0] = 'USPS'; $array[1] = 'EXPRESS MAIL INTL ENDICIA'; break;
|
99 |
+
case 'usps_4':
|
100 |
+
$array[0] = 'USPS'; $array[1] = 'PARCEL POST ENDICIA'; break;
|
101 |
+
case 'usps_16':
|
102 |
+
$array[0] = 'USPS'; $array[1] = 'Priority Mail FlatRateBox-ENV'; break;
|
103 |
+
case 'usps_17':
|
104 |
+
$array[0] = 'USPS'; $array[1] = 'Priority Mail FlatRateBox-M'; break;
|
105 |
+
case 'usps_22':
|
106 |
+
$array[0] = 'USPS'; $array[1] = 'Priority Mail FlatRateBox-L'; break;
|
107 |
+
case 'usps_28':
|
108 |
+
$array[0] = 'USPS'; $array[1] = 'Priority Mail FlatRateBox-S'; break;
|
109 |
+
case 'usps_42':
|
110 |
+
$array[0] = 'USPS'; $array[1] = 'Priority Mail FlatRateBox-ENV'; break;
|
111 |
+
case 'usps_61':
|
112 |
+
$array[0] = 'USPS'; $array[1] = 'FIRST CLASS'; break;
|
113 |
+
case 'usps_INT_1':
|
114 |
+
$array[0] = 'USPS'; $array[1] = 'EXPRESS MAIL INTL ENDICIA'; break;
|
115 |
+
case 'usps_INT_2':
|
116 |
+
$array[0] = 'USPS'; $array[1] = 'PRIORITY MAIL INTL ENDICIA'; break;
|
117 |
+
case 'usps_INT_14':
|
118 |
+
$array[0] = 'USPS'; $array[1] = 'FIRST CLASS'; break;
|
119 |
+
case 'usps_INT_15':
|
120 |
+
$array[0] = 'USPS'; $array[1] = 'First Class Mail International'; break;
|
121 |
+
|
122 |
+
// FEDEX default mapping
|
123 |
+
case 'fedex_FEDEX_1_DAY_FREIGHT':
|
124 |
+
$array[0] = 'FEDEX'; $array[1] = 'OVERNIGHT FREIGHT'; break;
|
125 |
+
case 'fedex_FEDEX_2_DAY_FREIGHT':
|
126 |
+
$array[0] = 'FEDEX'; $array[1] = '2DAY FREIGHT'; break;
|
127 |
+
case 'fedex_FEDEX_2_DAY':
|
128 |
+
$array[0] = 'FEDEX'; $array[1] = '2DAY'; break;
|
129 |
+
case 'fedex_FEDEX_EXPRESS_SAVER':
|
130 |
+
$array[0] = 'FEDEX'; $array[1] = 'EXPRESS SAVER'; break;
|
131 |
+
case 'fedex_FEDEX_GROUND':
|
132 |
+
$array[0] = 'FEDEX'; $array[1] = 'GROUND'; break;
|
133 |
+
case 'fedex_FIRST_OVERNIGHT':
|
134 |
+
$array[0] = 'FEDEX'; $array[1] = 'First Overnight'; break;
|
135 |
+
case 'fedex_GROUND_HOME_DELIVERY':
|
136 |
+
$array[0] = 'FEDEX'; $array[1] = 'HOME DELIVERY'; break;
|
137 |
+
case 'fedex_INTERNATIONAL_ECONOMY':
|
138 |
+
$array[0] = 'FEDEX'; $array[1] = 'INTERNATIONAL ECONOMY'; break;
|
139 |
+
case 'fedex_INTERNATIONAL_ECONOMY_FREIGHT':
|
140 |
+
$array[0] = 'FEDEX'; $array[1] = 'INTL ECONOMY FREIGHT'; break;
|
141 |
+
case 'fedex_INTERNATIONAL_PRIORITY':
|
142 |
+
$array[0] = 'FEDEX'; $array[1] = 'INTERNATIONAL PRIORITY'; break;
|
143 |
+
case 'fedex_INTERNATIONAL_PRIORITY_FREIGHT':
|
144 |
+
$array[0] = 'FEDEX'; $array[1] = 'INTL PRIORITY FREIGHT'; break;
|
145 |
+
case 'fedex_PRIORITY_OVERNIGHT':
|
146 |
+
$array[0] = 'FEDEX'; $array[1] = 'PRIORITY OVERNIGHT'; break;
|
147 |
+
case 'fedex_STANDARD_OVERNIGHT':
|
148 |
+
$array[0] = 'FEDEX'; $array[1] = 'STANDARD OVERNIGHT'; break;
|
149 |
+
case 'fedex_FEDEX_FREIGHT':
|
150 |
+
$array[0] = 'FEDEX'; $array[1] = 'FREIGHT'; break;
|
151 |
+
|
152 |
+
// UPS default mapping
|
153 |
+
case 'ups_1DM':
|
154 |
+
$array[0] = 'UPS'; $array[1] = 'NEXT DAY AIR EARLY AM'; break;
|
155 |
+
case 'ups_1DA':
|
156 |
+
$array[0] = 'UPS'; $array[1] = 'NEXT DAY AIR'; break;
|
157 |
+
case 'ups_1DP':
|
158 |
+
$array[0] = 'UPS'; $array[1] = 'NEXT DAY AIR SAVER'; break;
|
159 |
+
case 'ups_2DM':
|
160 |
+
$array[0] = 'UPS'; $array[1] = '2ND DAY AIR AM'; break;
|
161 |
+
case 'ups_2DA':
|
162 |
+
$array[0] = 'UPS'; $array[1] = '2ND DAY AIR'; break;
|
163 |
+
case 'ups_3DS':
|
164 |
+
$array[0] = 'UPS'; $array[1] = '3 DAY SELECT'; break;
|
165 |
+
case 'ups_GND':
|
166 |
+
$array[0] = 'UPS'; $array[1] = 'GROUND'; break;
|
167 |
+
case 'ups_GNDCOM':
|
168 |
+
$array[0] = 'UPS'; $array[1] = 'GROUND SERVICE COMMERCIAL'; break;
|
169 |
+
case 'ups_GNDRES':
|
170 |
+
$array[0] = 'UPS'; $array[1] = 'GROUND SERVICE RESIDENTIAL'; break;
|
171 |
+
case 'ups_STD':
|
172 |
+
$array[0] = 'UPS'; $array[1] = 'STANDARD TO CANADA'; break;
|
173 |
+
case 'ups_XPR':
|
174 |
+
$array[0] = 'UPS'; $array[1] = 'WORLDWIDE EXPRESS'; break;
|
175 |
+
case 'ups_WXS':
|
176 |
+
$array[0] = 'UPS'; $array[1] = 'WORLDWIDE EXPRESS SAVER'; break;
|
177 |
+
case 'ups_XPD':
|
178 |
+
$array[0] = 'UPS'; $array[1] = 'WORLDWIDE EXPEDITED'; break;
|
179 |
+
}
|
180 |
+
|
181 |
+
return $array;
|
182 |
+
}
|
183 |
+
|
184 |
+
public function generateAPICredentialsForStore($store_id) {
|
185 |
+
// Load full default settings
|
186 |
+
// It keeps track also of the shipping method settings that are not currently active
|
187 |
+
$APIUsername = Mage::getStoreConfig('dcl_fulfillment/general/api_username', $store_id);
|
188 |
+
if (empty($APIUsername)) {
|
189 |
+
$installer = new Mage_Eav_Model_Entity_Setup('core_setup');
|
190 |
+
$installer->startSetup();
|
191 |
+
|
192 |
+
$username = 'dcl_' . $this->generateRandomString(10);
|
193 |
+
$password = $this->generateRandomString(24);
|
194 |
+
$installer->setConfigData("dcl_fulfillment/general/api_username", $username, 'stores', $store_id);
|
195 |
+
$installer->setConfigData("dcl_fulfillment/general/api_key", $password, 'stores', $store_id);
|
196 |
+
|
197 |
+
$installer->endSetup();
|
198 |
+
return array($username, $password);
|
199 |
+
}
|
200 |
+
else {
|
201 |
+
return array(Mage::getStoreConfig('dcl_fulfillment/general/api_username', $store_id),
|
202 |
+
Mage::getStoreConfig('dcl_fulfillment/general/api_key', $store_id)
|
203 |
+
);
|
204 |
+
}
|
205 |
+
}
|
206 |
+
|
207 |
+
private function generateRandomString($length = 10) {
|
208 |
+
$characters = '23456789abcdefghjkmnpqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ';
|
209 |
+
$charactersLength = strlen($characters);
|
210 |
+
$randomString = '';
|
211 |
+
srand($this->make_seed());
|
212 |
+
for ($i = 0; $i < $length; $i++) {
|
213 |
+
$randomString .= $characters[rand(0, $charactersLength - 1)];
|
214 |
+
}
|
215 |
+
return $randomString;
|
216 |
+
}
|
217 |
+
|
218 |
+
private function make_seed()
|
219 |
+
{
|
220 |
+
list($usec, $sec) = explode(' ', microtime());
|
221 |
+
return (float) $sec + ((float) $usec * 100000);
|
222 |
+
}
|
223 |
+
|
224 |
+
public function isMageEnterprise() {
|
225 |
+
return Mage::getConfig ()->getModuleConfig ( 'Enterprise_Enterprise' ) && Mage::getConfig ()->getModuleConfig ( 'Enterprise_AdminGws' ) && Mage::getConfig ()->getModuleConfig ( 'Enterprise_Checkout' ) && Mage::getConfig ()->getModuleConfig ( 'Enterprise_Customer' );
|
226 |
+
}
|
227 |
+
|
228 |
+
public function isMageProfessional() {
|
229 |
+
return Mage::getConfig ()->getModuleConfig ( 'Enterprise_Enterprise' ) && !Mage::getConfig ()->getModuleConfig ( 'Enterprise_AdminGws' ) && !Mage::getConfig ()->getModuleConfig ( 'Enterprise_Checkout' ) && !Mage::getConfig ()->getModuleConfig ( 'Enterprise_Customer' );
|
230 |
+
}
|
231 |
+
|
232 |
+
public function isMageCommunity() {
|
233 |
+
return !$this->isMageEnterprise() && !$this->isMageProfessional();
|
234 |
+
}
|
235 |
+
}
|
236 |
+
|
237 |
+
?>
|
app/code/community/DCL/Fulfillment/Helper/Data.php
ADDED
@@ -0,0 +1,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class DCL_Fulfillment_Helper_Data extends Mage_Core_Helper_Abstract
|
4 |
+
{
|
5 |
+
}
|
6 |
+
|
7 |
+
?>
|
app/code/community/DCL/Fulfillment/Model/Acknowledgedorder.php
ADDED
@@ -0,0 +1,34 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* @author DCL
|
5 |
+
*/
|
6 |
+
|
7 |
+
class DCL_Fulfillment_Model_Acknowledgedorder extends Mage_Core_Model_Abstract
|
8 |
+
{
|
9 |
+
/**
|
10 |
+
* Define resource model
|
11 |
+
*/
|
12 |
+
protected function _construct()
|
13 |
+
{
|
14 |
+
// Called
|
15 |
+
$this->_init('dcl_fulfillment/acknowledgedorder');
|
16 |
+
}
|
17 |
+
|
18 |
+
/**
|
19 |
+
* If object is new adds creation date
|
20 |
+
*
|
21 |
+
* @return DCL_Fulfillment_Model_Shippingmethod
|
22 |
+
*/
|
23 |
+
protected function _beforeSave()
|
24 |
+
{
|
25 |
+
parent::_beforeSave();
|
26 |
+
if ($this->isObjectNew()) {
|
27 |
+
$this->setData('acknowledged_at', Varien_Date::now()); // GMT time
|
28 |
+
}
|
29 |
+
$this->setData('modified_at', Varien_Date::now()); // GMT time
|
30 |
+
return $this;
|
31 |
+
}
|
32 |
+
}
|
33 |
+
|
34 |
+
?>
|
app/code/community/DCL/Fulfillment/Model/Inventory.php
ADDED
@@ -0,0 +1,31 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* @author DCL
|
5 |
+
*/
|
6 |
+
|
7 |
+
class DCL_Fulfillment_Model_Inventory extends Mage_Core_Model_Abstract
|
8 |
+
{
|
9 |
+
/**
|
10 |
+
* Define resource model
|
11 |
+
*/
|
12 |
+
protected function _construct()
|
13 |
+
{
|
14 |
+
// Called
|
15 |
+
$this->_init('dcl_fulfillment/inventory');
|
16 |
+
}
|
17 |
+
|
18 |
+
/**
|
19 |
+
* If object is new adds creation date
|
20 |
+
*
|
21 |
+
* @return DCL_Fulfillment_Model_Shippingmethod
|
22 |
+
*/
|
23 |
+
protected function _beforeSave()
|
24 |
+
{
|
25 |
+
parent::_beforeSave();
|
26 |
+
$this->setData('modified_at', Varien_Date::now()); // GMT time
|
27 |
+
return $this;
|
28 |
+
}
|
29 |
+
}
|
30 |
+
|
31 |
+
?>
|
app/code/community/DCL/Fulfillment/Model/Observer.php
ADDED
@@ -0,0 +1,30 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* @author DCL
|
5 |
+
*/
|
6 |
+
|
7 |
+
class DCL_Fulfillment_Model_Observer
|
8 |
+
{
|
9 |
+
/**
|
10 |
+
* Joins extra tables for adding custom columns to Mage_Adminhtml_Block_Sales_Order_Grid
|
11 |
+
* @param $observer
|
12 |
+
*/
|
13 |
+
public function salesOrderGridCollectionLoadBefore($observer)
|
14 |
+
{
|
15 |
+
$collection = $observer->getOrderGridCollection();
|
16 |
+
$select = $collection->getSelect();
|
17 |
+
$select->joinLeft(array('ack_order'=> 'dcl_fulfillment_acknowledgedorder'), 'ack_order.order_id = main_table.entity_id', array('stage'=>'stage', 'stage_description' =>'stage_description' ));
|
18 |
+
}
|
19 |
+
|
20 |
+
public function onDisplayDCLFulfillmentSection(Varien_Event_Observer $observer)
|
21 |
+
{
|
22 |
+
if (strpos(Mage::helper('core/url')->getCurrentUrl(), 'section/dcl_fulfillment') !== FALSE ) {
|
23 |
+
// Add active shipping methods
|
24 |
+
Mage::helper('dcl_fulfillment/admin')->setDefaultShippingData();
|
25 |
+
}
|
26 |
+
return $this;
|
27 |
+
}
|
28 |
+
}
|
29 |
+
|
30 |
+
?>
|
app/code/community/DCL/Fulfillment/Model/Resource/Acknowledgedorder.php
ADDED
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Acknowledged Order item resource model
|
5 |
+
*
|
6 |
+
* @author DCL
|
7 |
+
*/
|
8 |
+
|
9 |
+
class DCL_Fulfillment_Model_Resource_Acknowledgedorder extends Mage_Core_Model_Resource_Db_Abstract
|
10 |
+
{
|
11 |
+
/**
|
12 |
+
* Initialize connection and define main table and primary key
|
13 |
+
*/
|
14 |
+
protected function _construct()
|
15 |
+
{
|
16 |
+
// Called
|
17 |
+
$this->_init('dcl_fulfillment/acknowledgedorder', 'entity_id');
|
18 |
+
}
|
19 |
+
}
|
20 |
+
|
21 |
+
?>
|
app/code/community/DCL/Fulfillment/Model/Resource/Acknowledgedorder/Collection.php
ADDED
@@ -0,0 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Acklowledged Order collection
|
5 |
+
*
|
6 |
+
* @author DCL
|
7 |
+
*/
|
8 |
+
|
9 |
+
class DCL_Fulfillment_Model_Resource_Acknowledgedorder_Collection extends Mage_Core_Model_Resource_Db_Collection_Abstract
|
10 |
+
{
|
11 |
+
/**
|
12 |
+
* Define collection model
|
13 |
+
*/
|
14 |
+
protected function _construct()
|
15 |
+
{
|
16 |
+
$this->_init('dcl_fulfillment/acknowledgedorder');
|
17 |
+
}
|
18 |
+
}
|
19 |
+
|
20 |
+
?>
|
app/code/community/DCL/Fulfillment/Model/Resource/Inventory.php
ADDED
@@ -0,0 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Inventory item resource model
|
5 |
+
*
|
6 |
+
* @author DCL
|
7 |
+
*/
|
8 |
+
|
9 |
+
class DCL_Fulfillment_Model_Resource_Inventory extends Mage_Core_Model_Resource_Db_Abstract
|
10 |
+
{
|
11 |
+
/**
|
12 |
+
* Initialize connection and define main table and primary key
|
13 |
+
*/
|
14 |
+
protected function _construct()
|
15 |
+
{
|
16 |
+
$this->_init('dcl_fulfillment/inventory', 'entity_id');
|
17 |
+
}
|
18 |
+
}
|
19 |
+
|
20 |
+
?>
|
app/code/community/DCL/Fulfillment/Model/Resource/Inventory/Collection.php
ADDED
@@ -0,0 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Inventory collection
|
5 |
+
*
|
6 |
+
* @author DCL
|
7 |
+
*/
|
8 |
+
|
9 |
+
class DCL_Fulfillment_Model_Resource_Inventory_Collection extends Mage_Core_Model_Resource_Db_Collection_Abstract
|
10 |
+
{
|
11 |
+
/**
|
12 |
+
* Define collection model
|
13 |
+
*/
|
14 |
+
protected function _construct()
|
15 |
+
{
|
16 |
+
$this->_init('dcl_fulfillment/inventory');
|
17 |
+
}
|
18 |
+
}
|
19 |
+
|
20 |
+
?>
|
app/code/community/DCL/Fulfillment/Model/System/Config/Source/Acknowledgestatus.php
ADDED
@@ -0,0 +1,51 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* @author DCL
|
5 |
+
*/
|
6 |
+
|
7 |
+
class DCL_Fulfillment_Model_System_Config_Source_Acknowledgestatus
|
8 |
+
{
|
9 |
+
/**
|
10 |
+
* Options getter
|
11 |
+
*
|
12 |
+
* @return array
|
13 |
+
*/
|
14 |
+
public function toOptionArray()
|
15 |
+
{
|
16 |
+
$orderStatusCollection = Mage::getModel('sales/order_status')->getResourceCollection()->getData();
|
17 |
+
$status = array();
|
18 |
+
$status= array(
|
19 |
+
'' => Mage::helper('adminhtml')->__('Select status (if needed)...')
|
20 |
+
);
|
21 |
+
foreach($orderStatusCollection as $orderStatus) {
|
22 |
+
if (!in_array($orderStatus['status'], array('canceled','closed','complete','fraud','paypal_reversed','pending_paypal','paypal_canceled_reversal','payment_review'))) {
|
23 |
+
$status[] = array (
|
24 |
+
'value' => $orderStatus['status'], 'label' => $orderStatus['label']
|
25 |
+
);
|
26 |
+
}
|
27 |
+
}
|
28 |
+
return $status;
|
29 |
+
}
|
30 |
+
|
31 |
+
/**
|
32 |
+
* Get options in "key-value" format
|
33 |
+
*
|
34 |
+
* @return array
|
35 |
+
*/
|
36 |
+
public function toArray()
|
37 |
+
{
|
38 |
+
$orderStatusCollection = Mage::getModel('sales/order_status')->getResourceCollection()->getData();
|
39 |
+
$status = array();
|
40 |
+
foreach($orderStatusCollection as $orderStatus) {
|
41 |
+
if (!in_array($orderStatus['status'], array('canceled','closed','complete','fraud','paypal_reversed','pending_paypal','paypal_canceled_reversal','payment_review'))) {
|
42 |
+
$status[] = array (
|
43 |
+
$orderStatus['status'] => $orderStatus['label']
|
44 |
+
);
|
45 |
+
}
|
46 |
+
}
|
47 |
+
return $status;
|
48 |
+
}
|
49 |
+
}
|
50 |
+
|
51 |
+
?>
|
app/code/community/DCL/Fulfillment/Model/System/Config/Source/Days.php
ADDED
@@ -0,0 +1,46 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* @author DCL
|
5 |
+
*/
|
6 |
+
|
7 |
+
class DCL_Fulfillment_Model_System_Config_Source_Days
|
8 |
+
{
|
9 |
+
/**
|
10 |
+
* Options getter
|
11 |
+
*
|
12 |
+
* @return array
|
13 |
+
*/
|
14 |
+
public function toOptionArray()
|
15 |
+
{
|
16 |
+
return array(
|
17 |
+
array('value' => 1, 'label'=>Mage::helper('adminhtml')->__('Monday')),
|
18 |
+
array('value' => 2, 'label'=>Mage::helper('adminhtml')->__('Tuesday ')),
|
19 |
+
array('value' => 3, 'label'=>Mage::helper('adminhtml')->__('Wednesday ')),
|
20 |
+
array('value' => 4, 'label'=>Mage::helper('adminhtml')->__('Thursday ')),
|
21 |
+
array('value' => 5, 'label'=>Mage::helper('adminhtml')->__('Friday ')),
|
22 |
+
array('value' => 6, 'label'=>Mage::helper('adminhtml')->__('Saturday ')),
|
23 |
+
array('value' => 0, 'label'=>Mage::helper('adminhtml')->__('Sunday ')),
|
24 |
+
);
|
25 |
+
}
|
26 |
+
|
27 |
+
/**
|
28 |
+
* Get options in "key-value" format
|
29 |
+
*
|
30 |
+
* @return array
|
31 |
+
*/
|
32 |
+
public function toArray()
|
33 |
+
{
|
34 |
+
return array(
|
35 |
+
1 => Mage::helper('adminhtml')->__('Monday'),
|
36 |
+
2 => Mage::helper('adminhtml')->__('Tuesday'),
|
37 |
+
3 => Mage::helper('adminhtml')->__('Wednesday'),
|
38 |
+
4 => Mage::helper('adminhtml')->__('Thursday'),
|
39 |
+
5 => Mage::helper('adminhtml')->__('Friday'),
|
40 |
+
6 => Mage::helper('adminhtml')->__('Saturday'),
|
41 |
+
0 => Mage::helper('adminhtml')->__('Sunday'),
|
42 |
+
);
|
43 |
+
}
|
44 |
+
}
|
45 |
+
|
46 |
+
?>
|
app/code/community/DCL/Fulfillment/Model/System/Config/Source/Orderage.php
ADDED
@@ -0,0 +1,48 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* @author DCL
|
5 |
+
*/
|
6 |
+
|
7 |
+
class DCL_Fulfillment_Model_System_Config_Source_Orderage
|
8 |
+
{
|
9 |
+
/**
|
10 |
+
* Options getter
|
11 |
+
*
|
12 |
+
* @return array
|
13 |
+
*/
|
14 |
+
public function toOptionArray()
|
15 |
+
{
|
16 |
+
return array(
|
17 |
+
array('value' => 0, 'label'=>Mage::helper('adminhtml')->__('No wait')),
|
18 |
+
array('value' => 30, 'label'=>Mage::helper('adminhtml')->__('30 min')),
|
19 |
+
array('value' => 60, 'label'=>Mage::helper('adminhtml')->__('1 hour')),
|
20 |
+
array('value' => 120, 'label'=>Mage::helper('adminhtml')->__('2 hours')),
|
21 |
+
array('value' => 240, 'label'=>Mage::helper('adminhtml')->__('4 hours')),
|
22 |
+
array('value' => 360, 'label'=>Mage::helper('adminhtml')->__('6 hours')),
|
23 |
+
array('value' => 720, 'label'=>Mage::helper('adminhtml')->__('12 hours')),
|
24 |
+
array('value' => 1440, 'label'=>Mage::helper('adminhtml')->__('1 day')),
|
25 |
+
);
|
26 |
+
}
|
27 |
+
|
28 |
+
/**
|
29 |
+
* Get options in "key-value" format
|
30 |
+
*
|
31 |
+
* @return array
|
32 |
+
*/
|
33 |
+
public function toArray()
|
34 |
+
{
|
35 |
+
return array(
|
36 |
+
0 => Mage::helper('adminhtml')->__('No wait'),
|
37 |
+
30 => Mage::helper('adminhtml')->__('30 min'),
|
38 |
+
60 => Mage::helper('adminhtml')->__('1 hour'),
|
39 |
+
120 => Mage::helper('adminhtml')->__('2 hours'),
|
40 |
+
240 => Mage::helper('adminhtml')->__('4 hours'),
|
41 |
+
360 => Mage::helper('adminhtml')->__('6 hours'),
|
42 |
+
720 => Mage::helper('adminhtml')->__('12 hours'),
|
43 |
+
1440 => Mage::helper('adminhtml')->__('1 day'),
|
44 |
+
);
|
45 |
+
}
|
46 |
+
}
|
47 |
+
|
48 |
+
?>
|
app/code/community/DCL/Fulfillment/Model/System/Config/Source/Statuslist.php
ADDED
@@ -0,0 +1,48 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* @author DCL
|
5 |
+
*/
|
6 |
+
|
7 |
+
class DCL_Fulfillment_Model_System_Config_Source_Statuslist
|
8 |
+
{
|
9 |
+
/**
|
10 |
+
* Options getter
|
11 |
+
*
|
12 |
+
* @return array
|
13 |
+
*/
|
14 |
+
public function toOptionArray()
|
15 |
+
{
|
16 |
+
$orderStatusCollection = Mage::getModel('sales/order_status')->getResourceCollection()->getData();
|
17 |
+
$status = array();
|
18 |
+
foreach($orderStatusCollection as $orderStatus) {
|
19 |
+
if (!in_array($orderStatus['status'], array('canceled','closed','complete','fraud'))) {
|
20 |
+
$status[] = array (
|
21 |
+
'value' => $orderStatus['status'], 'label' => $orderStatus['label']
|
22 |
+
);
|
23 |
+
}
|
24 |
+
}
|
25 |
+
return $status;
|
26 |
+
}
|
27 |
+
|
28 |
+
/**
|
29 |
+
* Get options in "key-value" format
|
30 |
+
*
|
31 |
+
* @return array
|
32 |
+
*/
|
33 |
+
public function toArray()
|
34 |
+
{
|
35 |
+
$orderStatusCollection = Mage::getModel('sales/order_status')->getResourceCollection()->getData();
|
36 |
+
$status = array();
|
37 |
+
foreach($orderStatusCollection as $orderStatus) {
|
38 |
+
if (!in_array($orderStatus['status'], array('canceled','closed','complete','fraud'))) {
|
39 |
+
$status[] = array (
|
40 |
+
$orderStatus['status'] => $orderStatus['label']
|
41 |
+
);
|
42 |
+
}
|
43 |
+
}
|
44 |
+
return $status;
|
45 |
+
}
|
46 |
+
}
|
47 |
+
|
48 |
+
?>
|
app/code/community/DCL/Fulfillment/controllers/ApiController.php
ADDED
@@ -0,0 +1,446 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* @author DCL
|
5 |
+
*/
|
6 |
+
|
7 |
+
class DCL_Fulfillment_ApiController extends Mage_Core_Controller_Front_Action
|
8 |
+
{
|
9 |
+
public function indexAction()
|
10 |
+
{
|
11 |
+
$parms = $this->getRequest()->getParams();
|
12 |
+
$is_authenticated = false;
|
13 |
+
$api = "";
|
14 |
+
|
15 |
+
if (isset($parms['api'])) $api = $parms['api'];
|
16 |
+
|
17 |
+
$store_id = -1;
|
18 |
+
try {
|
19 |
+
$store_id = $parms['store_id'];
|
20 |
+
}
|
21 |
+
catch (Exception $e) { } //
|
22 |
+
try {
|
23 |
+
$auth = $this->getRequest()->getHeader('X-EFACTORY-AUTH');
|
24 |
+
if ($store_id > 0) {
|
25 |
+
$base64 = base64_encode(Mage::getStoreConfig('dcl_fulfillment/general/api_username', $store_id) . ':' .
|
26 |
+
Mage::getStoreConfig('dcl_fulfillment/general/api_key', $store_id));
|
27 |
+
$is_authenticated = strcasecmp($base64, $auth) == 0;
|
28 |
+
}
|
29 |
+
}
|
30 |
+
catch (Exception $e) { } //
|
31 |
+
|
32 |
+
// ====================================================================================
|
33 |
+
if ($is_authenticated && $api == "settings") {
|
34 |
+
$allStores = Mage::app()->getStores();
|
35 |
+
$config = null;
|
36 |
+
foreach ($allStores as $_eachStoreId => $val)
|
37 |
+
{
|
38 |
+
$_storeId = Mage::app()->getStore($_eachStoreId)->getId();
|
39 |
+
if ($store_id != $_storeId) continue;
|
40 |
+
$configStore = Mage::getStoreConfig('dcl_fulfillment', $_storeId);
|
41 |
+
$configStore['general']['store_id'] = $_storeId;
|
42 |
+
$map_table = unserialize($configStore['shipping']['shippingtable']);
|
43 |
+
$configStore['shipping_methods'] = [];
|
44 |
+
unset($configStore['general']['api_username']);
|
45 |
+
unset($configStore['general']['api_password']);
|
46 |
+
unset($configStore['general']['efactory_username']);
|
47 |
+
unset($configStore['general']['efactory_password']);
|
48 |
+
|
49 |
+
foreach ($map_table as $key => $value) {
|
50 |
+
if (!empty($value['dcl_carrier'])) {
|
51 |
+
$configStore['shipping_methods'][] = $value;
|
52 |
+
}
|
53 |
+
}
|
54 |
+
unset($configStore['shipping']);
|
55 |
+
$config = $configStore;
|
56 |
+
}
|
57 |
+
header('Content-Type: application/json', true);
|
58 |
+
ob_end_clean();
|
59 |
+
$response['settings'] = $config;
|
60 |
+
echo json_encode($response);
|
61 |
+
}
|
62 |
+
// ====================================================================================
|
63 |
+
else if ($is_authenticated && $api == "open_orders") {
|
64 |
+
$orders = [];
|
65 |
+
|
66 |
+
$allStores = Mage::app()->getStores();
|
67 |
+
foreach ($allStores as $_eachStoreId => $val)
|
68 |
+
{
|
69 |
+
$_storeId = Mage::app()->getStore($_eachStoreId)->getId();
|
70 |
+
if ($store_id != $_storeId) continue;
|
71 |
+
|
72 |
+
$configStore = Mage::getStoreConfig('dcl_fulfillment', $_storeId);
|
73 |
+
|
74 |
+
// Check for store enabled condition ------------------------------
|
75 |
+
if ($configStore['general']['enabled'] == '0') continue;
|
76 |
+
// ----------------------------------------------------------------
|
77 |
+
|
78 |
+
// Check for day import condition ---------------------------------
|
79 |
+
$datetime_at_dcl = new DateTime("now", new DateTimeZone('America/Los_Angeles') );
|
80 |
+
$dw = date("w", $datetime_at_dcl->format('U')); // 0 = Sunday in Los Angeles time
|
81 |
+
if (!in_array($dw, explode(',',$configStore['general']['importdays']))) continue;
|
82 |
+
// ----------------------------------------------------------------
|
83 |
+
|
84 |
+
// Check for time import condition --------------------------------
|
85 |
+
$from_time_array = explode(',',$configStore['general']['importtimefrom']);
|
86 |
+
$from_time = $from_time_array[2] + $from_time_array[1] * 60 + $from_time_array[0] * 60 * 60;
|
87 |
+
|
88 |
+
$to_time_array = explode(',',$configStore['general']['importtimeto']);
|
89 |
+
$to_time = $to_time_array[2] + $to_time_array[1] * 60 + $to_time_array[0]*60*60;
|
90 |
+
|
91 |
+
$import_time_array = explode(',',$datetime_at_dcl->format('H,i,s'));
|
92 |
+
$import_time = $import_time_array[2] + $import_time_array[1] * 60 + $import_time_array[0] * 60 * 60;
|
93 |
+
if (!($import_time >= $from_time && $import_time <= $to_time)) continue;
|
94 |
+
// ----------------------------------------------------------------
|
95 |
+
|
96 |
+
$collection = Mage::getModel("sales/order")->getCollection()
|
97 |
+
|
98 |
+
// Check for status condition -------------------------------------
|
99 |
+
->addFieldToFilter('status',
|
100 |
+
array(
|
101 |
+
'in' => explode(',',$configStore['general']['processstatus'])
|
102 |
+
))
|
103 |
+
// ----------------------------------------------------------------
|
104 |
+
|
105 |
+
->addAttributeToFilter('store_id', $_storeId);
|
106 |
+
// ----------------------------------------------------------------
|
107 |
+
|
108 |
+
$now_gmt = Mage::app()->getLocale()->utcDate(null, Mage::getModel('core/date')->date('Y-m-d H:i:s'), true, Varien_Date::DATETIME_INTERNAL_FORMAT)->toString(Varien_Date::DATETIME_INTERNAL_FORMAT);
|
109 |
+
|
110 |
+
// Skip for order already acknowledged by DCL-------------------
|
111 |
+
$collection->getSelect()->joinLeft( array('ack_order'=> 'dcl_fulfillment_acknowledgedorder'), 'ack_order.order_id = main_table.entity_id', null)
|
112 |
+
->where("ack_order.order_id is null");
|
113 |
+
// ------------------------------------------------------------
|
114 |
+
|
115 |
+
foreach ($collection as $col) {
|
116 |
+
$order = new StdClass;
|
117 |
+
$order->order_id = $col->getId();
|
118 |
+
$order->incremental_id = $col->getIncrementId();
|
119 |
+
$order->store_id = $col->getStoreId();
|
120 |
+
$order->store_name = $col->getStoreName();
|
121 |
+
$order->status = $col->getStatus();
|
122 |
+
$order->created_at = $col->getCreatedAt(); // GMT date/time
|
123 |
+
|
124 |
+
// Check for order age condition ------------------------------
|
125 |
+
$start_date = new DateTime($now_gmt);
|
126 |
+
$since_start = $start_date->diff(new DateTime($col->getCreatedAt()));
|
127 |
+
$minutes = $since_start->days * 24 * 60;
|
128 |
+
$minutes += $since_start->h * 60;
|
129 |
+
$minutes += $since_start->i;
|
130 |
+
if ($minutes < (int)$configStore['general']['ordertime']) continue;
|
131 |
+
// ------------------------------------------------------------
|
132 |
+
|
133 |
+
$order->updated_at = $col->getUpdatedAt();
|
134 |
+
$order->customer_id = $col->getCustomerId();
|
135 |
+
|
136 |
+
$order->tax_amount = $col->getTaxAmount();
|
137 |
+
$order->shipping_amount = $col->getShippingAmount();
|
138 |
+
$order->discount_amount = $col->getDiscountAmount();
|
139 |
+
$order->subtotal = $col->getSubtotal();
|
140 |
+
$order->grand_total = $col->getGrandTotal();
|
141 |
+
$order->shipping_method = $col->getShippingMethod();
|
142 |
+
$order->shipping_description = $col->getShippingDescription();
|
143 |
+
|
144 |
+
$_shippingAddress = $col->getShippingAddress();
|
145 |
+
$order->shipping_address = new StdClass;
|
146 |
+
$order->shipping_address->name = trim($_shippingAddress->getFirstname()." ".$_shippingAddress->getLastname());
|
147 |
+
$order->shipping_address->company = $_shippingAddress->getCompany();
|
148 |
+
$order->shipping_address->email = $_shippingAddress->getEmail();
|
149 |
+
$order->shipping_address->phone = $_shippingAddress->getTelephone();
|
150 |
+
$order->shipping_address->address1 = $_shippingAddress->getStreet1();
|
151 |
+
$order->shipping_address->address2 = $_shippingAddress->getStreet2();
|
152 |
+
$order->shipping_address->city = $_shippingAddress->getCity();
|
153 |
+
$order->shipping_address->state = $_shippingAddress->getRegion();
|
154 |
+
$order->shipping_address->postal_code = $_shippingAddress->getPostcode();
|
155 |
+
$order->shipping_address->country_code = $_shippingAddress->getCountry_id();
|
156 |
+
|
157 |
+
$_billingAddress = $col->getBillingAddress();
|
158 |
+
$order->billing_address = new StdClass;
|
159 |
+
$order->billing_address->name = trim($_billingAddress->getFirstname()." ".$_billingAddress->getLastname());
|
160 |
+
$order->billing_address->company = $_billingAddress->getCompany();
|
161 |
+
$order->billing_address->email = $_billingAddress->getEmail();
|
162 |
+
$order->billing_address->phone = $_billingAddress->getTelephone();
|
163 |
+
$order->billing_address->address1 = $_billingAddress->getStreet1();
|
164 |
+
$order->billing_address->address2 = $_billingAddress->getStreet2();
|
165 |
+
$order->billing_address->city = $_billingAddress->getCity();
|
166 |
+
$order->billing_address->state = $_billingAddress->getRegion();
|
167 |
+
$order->billing_address->postal_code = $_billingAddress->getPostcode();
|
168 |
+
$order->billing_address->country_code = $_billingAddress->getCountry_id();
|
169 |
+
|
170 |
+
// Just in case someone add custom attributes to order
|
171 |
+
$ord = Mage::getModel('sales/order')->load($col->getId());
|
172 |
+
$order->shipping_instructions = $ord->getData('shipping_instructions');
|
173 |
+
$order->extra_field1 = $ord->getData('extra_field1');
|
174 |
+
$order->extra_field2 = $ord->getData('extra_field2');
|
175 |
+
$order->extra_field3 = $ord->getData('extra_field3');
|
176 |
+
$order->extra_field4 = $ord->getData('extra_field4');
|
177 |
+
$order->extra_field5 = $ord->getData('extra_field5');
|
178 |
+
|
179 |
+
$products = array();
|
180 |
+
$items = $col->getAllVisibleItems();
|
181 |
+
foreach($items as $i) {
|
182 |
+
$product_it['item_id'] = $i->getId();
|
183 |
+
$product_it['sku'] = $i->getSku();
|
184 |
+
$product_it['name'] = $i->getName();
|
185 |
+
$product_it['qty'] = (int)$i->getQtyOrdered();
|
186 |
+
$product_it['price'] = $i->getPrice();
|
187 |
+
|
188 |
+
// Just in case someone add custom attributes to product
|
189 |
+
$product = Mage::getModel('catalog/product')->load($i->getProductId());
|
190 |
+
$product_it['extra_field1'] = $product->getData('extra_field1'); // same as $product->getExtraField1();
|
191 |
+
$product_it['extra_field2'] = $product->getData('extra_field2');
|
192 |
+
$product_it['extra_field3'] = $product->getData('extra_field3');
|
193 |
+
$product_it['extra_field4'] = $product->getData('extra_field4');
|
194 |
+
$product_it['extra_field5'] = $product->getData('extra_field5');
|
195 |
+
|
196 |
+
$products[] = $product_it;
|
197 |
+
}
|
198 |
+
$order->items = $products;
|
199 |
+
|
200 |
+
$orders[] = $order;
|
201 |
+
}
|
202 |
+
}
|
203 |
+
header('Content-Type: application/json', true);
|
204 |
+
ob_end_clean();
|
205 |
+
$responde['orders'] = $orders;
|
206 |
+
echo json_encode($responde);
|
207 |
+
}
|
208 |
+
// ====================================================================================
|
209 |
+
else if ($is_authenticated && $api == "acknowledged_orders") {
|
210 |
+
// Example: data={"acknowledge_only": true, "orders": [3]}
|
211 |
+
$acknowledged_orders = [];
|
212 |
+
$post_orders = $this->getRequest()->getPost('data', null);
|
213 |
+
if (!empty($post_orders)) {
|
214 |
+
$response = json_decode($post_orders);
|
215 |
+
$order_ids = $response->orders;
|
216 |
+
foreach ($order_ids as $order_id) {
|
217 |
+
// Insert order_id into DCL acklowledge table
|
218 |
+
$model = Mage::getModel('dcl_fulfillment/acknowledgedorder');
|
219 |
+
$model->setData(array('order_id' => (int)$order_id, 'stage' => 0, 'stage_description' => ($response->acknowledge_only? 'Acknowledged Only': 'Acknowledged')));
|
220 |
+
try {
|
221 |
+
$model->save();
|
222 |
+
$order = Mage::getModel('sales/order')->load((int)$order_id);
|
223 |
+
if ($order) {
|
224 |
+
if ($store_id != $order->getStoreId()) continue;
|
225 |
+
// Add the comment and save the order
|
226 |
+
$order->addStatusHistoryComment('[DCL] Order transferred to DCL.', false);
|
227 |
+
|
228 |
+
// Change order status (if needed)
|
229 |
+
$configStore = Mage::getStoreConfig('dcl_fulfillment', $order->getStoreId());
|
230 |
+
$ack_status = $configStore['general']['acknowledgetatus'];
|
231 |
+
if (!empty($ack_status)) {
|
232 |
+
$order->setStatus($ack_status);
|
233 |
+
}
|
234 |
+
|
235 |
+
$order->save();
|
236 |
+
}
|
237 |
+
$acknowledged_orders[] = (int)$order_id;
|
238 |
+
}
|
239 |
+
catch (Exception $e) { } //
|
240 |
+
}
|
241 |
+
}
|
242 |
+
$obj = (object) array('acknowledged_orders' => $acknowledged_orders);
|
243 |
+
header('Content-Type: application/json', true);
|
244 |
+
ob_end_clean();
|
245 |
+
$responde['result'] = $obj;
|
246 |
+
echo json_encode($responde);
|
247 |
+
}
|
248 |
+
// ====================================================================================
|
249 |
+
else if ($is_authenticated && $api == "order_stages") {
|
250 |
+
// Example: data=[{"order_id": 5, "stage": 10, "stage_description": "Received"}, ...]
|
251 |
+
$order_updated = 0;
|
252 |
+
$post= $this->getRequest()->getPost('data', null);
|
253 |
+
if (!empty($post)) {
|
254 |
+
$order_list = json_decode($post);
|
255 |
+
foreach ($order_list as $order_obj) {
|
256 |
+
$order_id = (int)$order_obj->order_id;
|
257 |
+
$order = Mage::getModel('sales/order')->load($order_id);
|
258 |
+
if ($order) {
|
259 |
+
if ($store_id != $order->getStoreId()) continue;
|
260 |
+
// Add the comment and save the order
|
261 |
+
$order->addStatusHistoryComment('[DCL] Order stage: ' . $order_obj->stage_description .'.', false);
|
262 |
+
try {
|
263 |
+
$order->save();
|
264 |
+
$order_updated++;
|
265 |
+
|
266 |
+
$model = Mage::getModel('dcl_fulfillment/acknowledgedorder')
|
267 |
+
->getCollection()
|
268 |
+
->addFieldToFilter('order_id', array('eq' => $order_id))
|
269 |
+
->getFirstItem();
|
270 |
+
if ($model) {
|
271 |
+
try {
|
272 |
+
$model->addData(array('order_id' => $order_id, 'stage' => $order_obj->stage, 'stage_description' => $order_obj->stage_description));
|
273 |
+
$model->save();
|
274 |
+
}
|
275 |
+
catch (Exception $e) { } //
|
276 |
+
}
|
277 |
+
}
|
278 |
+
catch (Exception $e) { } //
|
279 |
+
}
|
280 |
+
}
|
281 |
+
}
|
282 |
+
$obj = (object) array('order_updated' => $order_updated);
|
283 |
+
header('Content-Type: application/json', true);
|
284 |
+
ob_end_clean();
|
285 |
+
$responde['result'] = $obj;
|
286 |
+
echo json_encode($responde);
|
287 |
+
}
|
288 |
+
// ====================================================================================
|
289 |
+
else if ($is_authenticated && $api == "order_fulfillments") {
|
290 |
+
// Example: data=[{"order_id": 3, "carrier": "UPS", "service": "GROUND", "tracking_number": "1Z921321764238", "items": [{"sku": "3", "qty": 1}] }, ...]
|
291 |
+
|
292 |
+
$fulfillments = 0;
|
293 |
+
$post = $this->getRequest()->getPost('data', null);
|
294 |
+
if (!empty($post)) {
|
295 |
+
$order_list = json_decode($post);
|
296 |
+
foreach ($order_list as $order_obj) {
|
297 |
+
$order_id = $order_obj->order_id;
|
298 |
+
|
299 |
+
$order = Mage::getModel('sales/order')->load($order_id);
|
300 |
+
if ($order && $order->canShip()) {
|
301 |
+
if ($store_id != $order->getStoreId()) continue;
|
302 |
+
$shipped_items = array();
|
303 |
+
$items[] = $order_obj->items;
|
304 |
+
foreach ($order_obj->items as $item) {
|
305 |
+
$shipped_items[$item->sku] = $item->qty;
|
306 |
+
}
|
307 |
+
|
308 |
+
$configStore = Mage::getStoreConfig('dcl_fulfillment', $order->getStoreId());
|
309 |
+
$notify = $configStore['general']['notification'];
|
310 |
+
try {
|
311 |
+
$shipment = $order->prepareShipment($shipped_items);
|
312 |
+
if ($shipment) {
|
313 |
+
$shipment->register();
|
314 |
+
if ($notify == '1') {
|
315 |
+
$shipment->setEmailSent(true);
|
316 |
+
}
|
317 |
+
$shipment->getOrder()->setIsInProcess(true);
|
318 |
+
try {
|
319 |
+
$transactionSave = Mage::getModel('core/resource_transaction')
|
320 |
+
->addObject($shipment)
|
321 |
+
->addObject($shipment->getOrder())
|
322 |
+
->save();
|
323 |
+
$shipment->sendEmail($notify == '1', '');
|
324 |
+
} catch (Mage_Core_Exception $e) {
|
325 |
+
//
|
326 |
+
}
|
327 |
+
$shipmentId = $shipment->getIncrementId();
|
328 |
+
$carrier = '';
|
329 |
+
switch (strtolower($order_obj->carrier))
|
330 |
+
{
|
331 |
+
// Standard Magento carriers
|
332 |
+
case "ups":
|
333 |
+
case "usps":
|
334 |
+
case "fedex":
|
335 |
+
case "dhl":
|
336 |
+
$carrier = strtolower($order_obj->carrier);
|
337 |
+
break;
|
338 |
+
default:
|
339 |
+
$carrier = "custom";
|
340 |
+
break;
|
341 |
+
}
|
342 |
+
|
343 |
+
Mage::getModel('sales/order_shipment_api')
|
344 |
+
->addTrack($shipmentId, $carrier, $order_obj->service, $order_obj->tracking_number);
|
345 |
+
|
346 |
+
$fulfillments++;
|
347 |
+
}
|
348 |
+
}
|
349 |
+
catch (Exception $e) { } //
|
350 |
+
}
|
351 |
+
}
|
352 |
+
}
|
353 |
+
$obj = (object) array('order_fulfilled' => $fulfillments);
|
354 |
+
header('Content-Type: application/json', true);
|
355 |
+
ob_end_clean();
|
356 |
+
echo json_encode($obj);
|
357 |
+
}
|
358 |
+
// ====================================================================================
|
359 |
+
else if ($is_authenticated && $api == "inventory") {
|
360 |
+
// Store independent
|
361 |
+
// Example: data={"1002-002-DEMO2": 10, "1003-003-DEMO3": 5, ...}
|
362 |
+
$obj = null;
|
363 |
+
$post = $this->getRequest()->getPost('data', null);
|
364 |
+
if (!empty($post)) {
|
365 |
+
// POST
|
366 |
+
$sku_updated = 0;
|
367 |
+
$configStore = Mage::getStoreConfig('dcl_fulfillment'); // Common to all stores
|
368 |
+
if ($configStore['general']['inventory'] == '1') {
|
369 |
+
$sku_qty = json_decode($post);
|
370 |
+
foreach ($sku_qty as $sku => $qty) {
|
371 |
+
$product = Mage::getModel('catalog/product')->loadByAttribute('sku', $sku);
|
372 |
+
if ($product) {
|
373 |
+
$productId = $product->getId();
|
374 |
+
$stockItem =Mage::getModel('cataloginventory/stock_item')->loadByProduct($productId);
|
375 |
+
|
376 |
+
if ($configStore['general']['instock'] == '1' && (int)$qty > 0) {
|
377 |
+
$stockItem->setData('is_in_stock', 1);
|
378 |
+
}
|
379 |
+
$stockItem->setData('qty', (int)$qty);
|
380 |
+
|
381 |
+
try {
|
382 |
+
$stockItem->save();
|
383 |
+
$sku_updated++;
|
384 |
+
|
385 |
+
// Add/update DCL inventory table
|
386 |
+
$model = Mage::getModel('dcl_fulfillment/inventory')
|
387 |
+
->getCollection()
|
388 |
+
->addFieldToFilter('sku', array('eq' => $sku))
|
389 |
+
->getFirstItem();
|
390 |
+
if ($model) {
|
391 |
+
try {
|
392 |
+
$model->addData(array('sku' => $sku, 'qty' => (int)$qty));
|
393 |
+
$model->save();
|
394 |
+
}
|
395 |
+
catch (Exception $e) { } //
|
396 |
+
}
|
397 |
+
else {
|
398 |
+
$model = Mage::getModel('dcl_fulfillment/inventory');
|
399 |
+
try {
|
400 |
+
$model->setData(array('sku' => $sku, 'qty' => (int)$qty));
|
401 |
+
$model->save();
|
402 |
+
}
|
403 |
+
catch (Exception $e) { } //
|
404 |
+
}
|
405 |
+
}
|
406 |
+
catch (Exception $e) { } //
|
407 |
+
}
|
408 |
+
}
|
409 |
+
}
|
410 |
+
$obj = (object) array('sku_updated' => $sku_updated);
|
411 |
+
$responde['result'] = $obj;
|
412 |
+
}
|
413 |
+
else {
|
414 |
+
// GET
|
415 |
+
$products = [];
|
416 |
+
$productCollection = Mage::getModel('catalog/product')->getCollection();
|
417 |
+
foreach ($productCollection as $product) {
|
418 |
+
$productId = $product->getId();
|
419 |
+
$stockItem =Mage::getModel('cataloginventory/stock_item')->loadByProduct($productId);
|
420 |
+
$products[] = array('sku' => $product->sku, 'qty' => (int)$stockItem->getData('qty'));
|
421 |
+
}
|
422 |
+
$responde['result'] = $products;
|
423 |
+
}
|
424 |
+
header('Content-Type: application/json', true);
|
425 |
+
ob_end_clean();
|
426 |
+
echo json_encode($responde);
|
427 |
+
}
|
428 |
+
// ====================================================================================
|
429 |
+
else { // Do not return any clue about authorization required! Return info for troubleshooting.
|
430 |
+
$obj = (object) array('plugin_name' => 'dcl_fulfillment',
|
431 |
+
'plugin_version' => (string)Mage::getConfig()->getModuleConfig('DCL_Fulfillment')->version,
|
432 |
+
'is_magento_enterprise' => Mage::helper('dcl_fulfillment/admin')->isMageEnterprise(),
|
433 |
+
'is_magento_professional' => Mage::helper('dcl_fulfillment/admin')->isMageProfessional(),
|
434 |
+
'is_magento_community' => Mage::helper('dcl_fulfillment/admin')->isMageCommunity(),
|
435 |
+
'magento_version' => Mage::getVersion(),
|
436 |
+
'php_version' => phpversion(),
|
437 |
+
'os' => php_uname(),
|
438 |
+
);
|
439 |
+
header('Content-Type: application/json', true);
|
440 |
+
ob_end_clean();
|
441 |
+
echo json_encode($obj);
|
442 |
+
}
|
443 |
+
}
|
444 |
+
}
|
445 |
+
|
446 |
+
?>
|
app/code/community/DCL/Fulfillment/controllers/RegisterController.php
ADDED
@@ -0,0 +1,66 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* @author DCL
|
5 |
+
*/
|
6 |
+
|
7 |
+
class DCL_Fulfillment_RegisterController extends Mage_Adminhtml_Controller_Action
|
8 |
+
{
|
9 |
+
public function indexAction()
|
10 |
+
{
|
11 |
+
$data = json_decode($this->getRequest()->getPost('data', null));
|
12 |
+
if ($data->account_number == '') {
|
13 |
+
$user_pw = Mage::helper('dcl_fulfillment/admin')->generateAPICredentialsForStore($data->store_id);
|
14 |
+
|
15 |
+
if (is_array($user_pw)) {
|
16 |
+
$data->api_username = $user_pw[0];
|
17 |
+
$data->api_key = $user_pw[1];
|
18 |
+
}
|
19 |
+
}
|
20 |
+
|
21 |
+
$setup_store['data'] = json_encode($data);
|
22 |
+
|
23 |
+
$ch = curl_init();
|
24 |
+
|
25 |
+
curl_setopt($ch,CURLOPT_URL, "https://ecommerce.dclcorp.com/magento/setup"); //set URL
|
26 |
+
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
|
27 |
+
curl_setopt($ch,CURLOPT_POST, 1);
|
28 |
+
curl_setopt($ch,CURLOPT_POSTFIELDS, $setup_store);
|
29 |
+
curl_setopt($ch, CURLOPT_TIMEOUT, 30);
|
30 |
+
|
31 |
+
//execute post
|
32 |
+
$result = curl_exec($ch);
|
33 |
+
|
34 |
+
//close connection
|
35 |
+
curl_close($ch);
|
36 |
+
|
37 |
+
$server_result = json_decode($result);
|
38 |
+
|
39 |
+
if ($server_result && $server_result->error_code == 0) {
|
40 |
+
|
41 |
+
$installer = new Mage_Eav_Model_Entity_Setup('core_setup');
|
42 |
+
$installer->startSetup();
|
43 |
+
|
44 |
+
$installer->setConfigData("dcl_fulfillment/general/account_number", $server_result->account_number, "stores", $data->store_id);
|
45 |
+
|
46 |
+
if ($server_result->account_number == '') {
|
47 |
+
$installer->setConfigData("dcl_fulfillment/general/efactory_username", "", "stores", $data->store_id);
|
48 |
+
$installer->setConfigData("dcl_fulfillment/general/efactory_password", "", "stores", $data->store_id);
|
49 |
+
$installer->setConfigData("dcl_fulfillment/general/api_username", "", "stores", $data->store_id);
|
50 |
+
$installer->setConfigData("dcl_fulfillment/general/api_key", "", "stores", $data->store_id);
|
51 |
+
}
|
52 |
+
else {
|
53 |
+
$input = json_decode($this->getRequest()->getPost('data', null));
|
54 |
+
$installer->setConfigData("dcl_fulfillment/general/efactory_username", $input->efactory_username, "stores", $data->store_id);
|
55 |
+
$installer->setConfigData("dcl_fulfillment/general/efactory_password", $input->efactory_password, "stores", $data->store_id);
|
56 |
+
}
|
57 |
+
|
58 |
+
$installer->endSetup();
|
59 |
+
}
|
60 |
+
header('Content-Type: application/json', true);
|
61 |
+
ob_end_clean();
|
62 |
+
echo $result;
|
63 |
+
}
|
64 |
+
}
|
65 |
+
|
66 |
+
?>
|
app/code/community/DCL/Fulfillment/etc/adminhtml.xml
ADDED
@@ -0,0 +1,29 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<config>
|
3 |
+
<acl>
|
4 |
+
<resources>
|
5 |
+
<all>
|
6 |
+
<title>Allow Everything</title>
|
7 |
+
</all>
|
8 |
+
<admin>
|
9 |
+
<children>
|
10 |
+
<system>
|
11 |
+
<children>
|
12 |
+
<config>
|
13 |
+
<children>
|
14 |
+
<dcl_fulfillment translate="title">
|
15 |
+
<title>DCL Fulfillment</title>
|
16 |
+
<sort_order>100</sort_order>
|
17 |
+
</dcl_fulfillment>
|
18 |
+
</children>
|
19 |
+
</config>
|
20 |
+
</children>
|
21 |
+
</system>
|
22 |
+
<dcl_fulfillment_efactory>
|
23 |
+
<title>DCL Fulfillment</title>
|
24 |
+
</dcl_fulfillment_efactory>
|
25 |
+
</children>
|
26 |
+
</admin>
|
27 |
+
</resources>
|
28 |
+
</acl>
|
29 |
+
</config>
|
app/code/community/DCL/Fulfillment/etc/config.xml
ADDED
@@ -0,0 +1,136 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<!--
|
3 |
+
|
4 |
+
/**
|
5 |
+
* Module configuraton
|
6 |
+
*
|
7 |
+
* @author DCL
|
8 |
+
*/
|
9 |
+
|
10 |
+
-->
|
11 |
+
|
12 |
+
<config>
|
13 |
+
<modules>
|
14 |
+
<DCL_Fulfillment>
|
15 |
+
<version>1.0.0</version>
|
16 |
+
</DCL_Fulfillment>
|
17 |
+
</modules>
|
18 |
+
<global>
|
19 |
+
<models>
|
20 |
+
<dcl_fulfillment>
|
21 |
+
<class>DCL_Fulfillment_Model</class>
|
22 |
+
<resourceModel>dcl_fulfillment_resource</resourceModel>
|
23 |
+
</dcl_fulfillment>
|
24 |
+
<dcl_fulfillment_resource>
|
25 |
+
<class>DCL_Fulfillment_Model_Resource</class>
|
26 |
+
<entities>
|
27 |
+
<acknowledgedorder>
|
28 |
+
<table>dcl_fulfillment_acknowledgedorder</table>
|
29 |
+
</acknowledgedorder>
|
30 |
+
<inventory>
|
31 |
+
<table>dcl_fulfillment_inventory</table>
|
32 |
+
</inventory>
|
33 |
+
</entities>
|
34 |
+
</dcl_fulfillment_resource>
|
35 |
+
</models>
|
36 |
+
<helpers>
|
37 |
+
<dcl_fulfillment>
|
38 |
+
<class>DCL_Fulfillment_Helper</class>
|
39 |
+
</dcl_fulfillment>
|
40 |
+
</helpers>
|
41 |
+
<blocks>
|
42 |
+
<dcl_fulfillment>
|
43 |
+
<class>DCL_Fulfillment_Block</class>
|
44 |
+
</dcl_fulfillment>
|
45 |
+
</blocks>
|
46 |
+
<resources>
|
47 |
+
<dcl_fulfillment_setup>
|
48 |
+
<setup>
|
49 |
+
<module>DCL_Fulfillment</module>
|
50 |
+
<class>Mage_Core_Model_Resource_Setup</class>
|
51 |
+
</setup>
|
52 |
+
</dcl_fulfillment_setup>
|
53 |
+
</resources>
|
54 |
+
<events>
|
55 |
+
<adminhtml_init_system_config>
|
56 |
+
<observers>
|
57 |
+
<dcl_fulfillment_init_system_config>
|
58 |
+
<model>dcl_fulfillment/observer</model>
|
59 |
+
<method>onDisplayDCLFulfillmentSection</method>
|
60 |
+
</dcl_fulfillment_init_system_config>
|
61 |
+
</observers>
|
62 |
+
</adminhtml_init_system_config>
|
63 |
+
</events>
|
64 |
+
</global>
|
65 |
+
<frontend>
|
66 |
+
<routers>
|
67 |
+
<connector>
|
68 |
+
<use>standard</use>
|
69 |
+
<args>
|
70 |
+
<module>DCL_Fulfillment</module>
|
71 |
+
<frontName>dcl_fulfillment</frontName>
|
72 |
+
</args>
|
73 |
+
</connector>
|
74 |
+
</routers>
|
75 |
+
</frontend>
|
76 |
+
<!--<admin>
|
77 |
+
<routers>
|
78 |
+
<adminhtml>
|
79 |
+
<args>
|
80 |
+
<modules>
|
81 |
+
<DCL_Fulfillment before="Mage_Adminhtml">DCL_Fulfillment_Adminhtml</DCL_Fulfillment>
|
82 |
+
</modules>
|
83 |
+
</args>
|
84 |
+
</adminhtml>
|
85 |
+
</routers>
|
86 |
+
</admin>
|
87 |
+
-->
|
88 |
+
<admin>
|
89 |
+
<routers>
|
90 |
+
<adminhtml>
|
91 |
+
<args>
|
92 |
+
<modules>
|
93 |
+
<DCL_Fulfillment before="Mage_Adminhtml">DCL_Fulfillment</DCL_Fulfillment>
|
94 |
+
</modules>
|
95 |
+
</args>
|
96 |
+
</adminhtml>
|
97 |
+
</routers>
|
98 |
+
</admin>
|
99 |
+
|
100 |
+
<adminhtml>
|
101 |
+
<layout>
|
102 |
+
<updates>
|
103 |
+
<dcl_fulfillment>
|
104 |
+
<file>dcl_fulfillment.xml</file>
|
105 |
+
</dcl_fulfillment>
|
106 |
+
</updates>
|
107 |
+
</layout>
|
108 |
+
<events>
|
109 |
+
<sales_order_grid_collection_load_before>
|
110 |
+
<observers>
|
111 |
+
<dcl_fulfillment>
|
112 |
+
<model>dcl_fulfillment/observer</model>
|
113 |
+
<method>salesOrderGridCollectionLoadBefore</method>
|
114 |
+
</dcl_fulfillment>
|
115 |
+
</observers>
|
116 |
+
</sales_order_grid_collection_load_before>
|
117 |
+
</events>
|
118 |
+
</adminhtml>
|
119 |
+
<default>
|
120 |
+
<dcl_fulfillment>
|
121 |
+
<general>
|
122 |
+
<enabled>0</enabled>
|
123 |
+
<acknowledgeonly>1</acknowledgeonly>
|
124 |
+
<price>0</price>
|
125 |
+
<notification>1</notification>
|
126 |
+
<inventory>0</inventory>
|
127 |
+
<instock>1</instock>
|
128 |
+
<importtimefrom>00,00,00</importtimefrom>
|
129 |
+
<importtimeto>23,59,59</importtimeto>
|
130 |
+
<importdays>0,1,2,3,4,5,6</importdays>
|
131 |
+
<processstatus>processing</processstatus>
|
132 |
+
<ordertime>120</ordertime>
|
133 |
+
</general>
|
134 |
+
</dcl_fulfillment>
|
135 |
+
</default>
|
136 |
+
</config>
|
app/code/community/DCL/Fulfillment/etc/system.xml
ADDED
@@ -0,0 +1,251 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0" encoding="UTF-8"?>
|
2 |
+
<!--
|
3 |
+
/*
|
4 |
+
* @author DCL
|
5 |
+
*
|
6 |
+
*/
|
7 |
+
-->
|
8 |
+
<config>
|
9 |
+
<tabs>
|
10 |
+
<dcl_fulfillment_tab translate="label" module="dcl_fulfillment">
|
11 |
+
<label>DCL Fulfillment</label>
|
12 |
+
<sort_order>101</sort_order>
|
13 |
+
</dcl_fulfillment_tab>
|
14 |
+
</tabs>
|
15 |
+
<sections>
|
16 |
+
<dcl_fulfillment translate="label" module="dcl_fulfillment">
|
17 |
+
<label>Settings</label>
|
18 |
+
<tab>dcl_fulfillment_tab</tab>
|
19 |
+
<frontend_type>text</frontend_type>
|
20 |
+
<sort_order>1</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 |
+
<groups>
|
25 |
+
<general translate="label" module="dcl_fulfillment">
|
26 |
+
<label>General settings</label>
|
27 |
+
<tab>dcl_fulfillment_tab</tab>
|
28 |
+
<sort_order>0</sort_order>
|
29 |
+
<show_in_default>1</show_in_default>
|
30 |
+
<show_in_website>1</show_in_website>
|
31 |
+
<show_in_store>1</show_in_store>
|
32 |
+
<expanded>1</expanded>
|
33 |
+
<comment><![CDATA[
|
34 |
+
<a href="http://www.dclcorp.com" target="_blank"><IMG border="0" src="/skin/adminhtml/default/default/images/dcl_fulfillment_logo.png"></a>
|
35 |
+
<div style="margin-top:4px;margin-bottom:4px; color:gray;"></div>
|
36 |
+
<div style="margin-top:4px;"><b>For assistance please contact: <a href="mailto:sales@dclcorp.com">sales@dclcorp.com</a></b></div>
|
37 |
+
<br />
|
38 |
+
<span style="color: #eb5e00; font-weight: bold">To link a store to an eFactory account, please select the specific store from the "Current Configuration Scope".</span><br />
|
39 |
+
<hr /><br />
|
40 |
+
]]>
|
41 |
+
</comment>
|
42 |
+
<fields>
|
43 |
+
<efactory_username translate="label">
|
44 |
+
<label>eFactory Username</label>
|
45 |
+
<frontend_model>dcl_fulfillment/adminhtml_config_form_readonlyconditionalfield</frontend_model>
|
46 |
+
<sort_order>4</sort_order>
|
47 |
+
<show_in_default>0</show_in_default>
|
48 |
+
<show_in_website>0</show_in_website>
|
49 |
+
<show_in_store>1</show_in_store>
|
50 |
+
</efactory_username>
|
51 |
+
<efactory_password translate="label">
|
52 |
+
<label>eFactory Password</label>
|
53 |
+
<frontend_model>dcl_fulfillment/adminhtml_config_form_readonlyconditionalfield</frontend_model>
|
54 |
+
<frontend_type>password</frontend_type>
|
55 |
+
<sort_order>5</sort_order>
|
56 |
+
<show_in_default>0</show_in_default>
|
57 |
+
<show_in_website>0</show_in_website>
|
58 |
+
<show_in_store>1</show_in_store>
|
59 |
+
</efactory_password>
|
60 |
+
<account_number translate="label">
|
61 |
+
<label>eFactory Account Number</label>
|
62 |
+
<frontend_model>dcl_fulfillment/adminhtml_config_form_accountnumber</frontend_model>
|
63 |
+
<sort_order>6</sort_order>
|
64 |
+
<show_in_default>0</show_in_default>
|
65 |
+
<show_in_website>0</show_in_website>
|
66 |
+
<show_in_store>1</show_in_store>
|
67 |
+
</account_number>
|
68 |
+
<link_button translate="label">
|
69 |
+
<label></label>
|
70 |
+
<sort_order>9</sort_order>
|
71 |
+
<frontend_type>button</frontend_type>
|
72 |
+
<frontend_model>dcl_fulfillment/adminhtml_config_form_link</frontend_model>
|
73 |
+
<comment><![CDATA[
|
74 |
+
Link this Magento Store to a DCL eFactory account
|
75 |
+
<br /><hr /><br />
|
76 |
+
]]>
|
77 |
+
</comment>
|
78 |
+
<show_in_default>0</show_in_default>
|
79 |
+
<show_in_website>0</show_in_website>
|
80 |
+
<show_in_store>1</show_in_store>
|
81 |
+
</link_button>
|
82 |
+
<enabled translate="label">
|
83 |
+
<label>Enable DCL API</label>
|
84 |
+
<comment>
|
85 |
+
<![CDATA[Enable DCL background processes to acknowledge and fulfill orders, and update stock quantity.]]>
|
86 |
+
</comment>
|
87 |
+
<frontend_type>select</frontend_type>
|
88 |
+
<source_model>adminhtml/system_config_source_yesno</source_model>
|
89 |
+
<sort_order>10</sort_order>
|
90 |
+
<show_in_default>1</show_in_default>
|
91 |
+
<show_in_website>1</show_in_website>
|
92 |
+
<show_in_store>1</show_in_store>
|
93 |
+
</enabled>
|
94 |
+
<acknowledgeonly translate="label">
|
95 |
+
<label>Acknowledge Only</label>
|
96 |
+
<comment>
|
97 |
+
<![CDATA[DCL will only acknowledge orders but not fulfill unless requested.]]>
|
98 |
+
</comment>
|
99 |
+
<frontend_type>select</frontend_type>
|
100 |
+
<source_model>adminhtml/system_config_source_yesno</source_model>
|
101 |
+
<sort_order>11</sort_order>
|
102 |
+
<show_in_default>1</show_in_default>
|
103 |
+
<show_in_website>1</show_in_website>
|
104 |
+
<show_in_store>1</show_in_store>
|
105 |
+
</acknowledgeonly>
|
106 |
+
<price translate="label">
|
107 |
+
<label>Prices on Packing List</label>
|
108 |
+
<comment>
|
109 |
+
<![CDATA[All order prices will be printed on the Packing List document.]]>
|
110 |
+
</comment>
|
111 |
+
<frontend_type>select</frontend_type>
|
112 |
+
<source_model>adminhtml/system_config_source_yesno</source_model>
|
113 |
+
<sort_order>12</sort_order>
|
114 |
+
<show_in_default>1</show_in_default>
|
115 |
+
<show_in_website>1</show_in_website>
|
116 |
+
<show_in_store>1</show_in_store>
|
117 |
+
</price>
|
118 |
+
<notification translate="label">
|
119 |
+
<label>Magento Fulfillment Notification</label>
|
120 |
+
<comment>
|
121 |
+
<![CDATA[Magento will email ship notification to customers upon DCL fulfillment.]]>
|
122 |
+
</comment>
|
123 |
+
<frontend_type>select</frontend_type>
|
124 |
+
<source_model>adminhtml/system_config_source_yesno</source_model>
|
125 |
+
<sort_order>13</sort_order>
|
126 |
+
<show_in_default>1</show_in_default>
|
127 |
+
<show_in_website>1</show_in_website>
|
128 |
+
<show_in_store>1</show_in_store>
|
129 |
+
</notification>
|
130 |
+
<inventory translate="label">
|
131 |
+
<label>Update Inventory</label>
|
132 |
+
<comment>
|
133 |
+
<![CDATA[DCL will update Magento inventory.]]>
|
134 |
+
</comment>
|
135 |
+
<frontend_type>select</frontend_type>
|
136 |
+
<source_model>adminhtml/system_config_source_yesno</source_model>
|
137 |
+
<sort_order>14</sort_order>
|
138 |
+
<show_in_default>1</show_in_default>
|
139 |
+
<show_in_website>0</show_in_website>
|
140 |
+
<show_in_store>0</show_in_store>
|
141 |
+
</inventory>
|
142 |
+
<instock translate="label">
|
143 |
+
<label>In Stock</label>
|
144 |
+
<comment>
|
145 |
+
<![CDATA[DCL will force item in stock when quantity > 0.]]>
|
146 |
+
</comment>
|
147 |
+
<frontend_type>select</frontend_type>
|
148 |
+
<source_model>adminhtml/system_config_source_yesno</source_model>
|
149 |
+
<sort_order>15</sort_order>
|
150 |
+
<show_in_default>1</show_in_default>
|
151 |
+
<show_in_website>0</show_in_website>
|
152 |
+
<show_in_store>0</show_in_store>
|
153 |
+
</instock>
|
154 |
+
<processstatus translate="label">
|
155 |
+
<label>Process Status</label>
|
156 |
+
<comment>
|
157 |
+
<![CDATA[DCL will process orders with selected status.]]>
|
158 |
+
</comment>
|
159 |
+
<frontend_type>multiselect</frontend_type>
|
160 |
+
<source_model>dcl_fulfillment/system_config_source_statuslist</source_model>
|
161 |
+
<sort_order>16</sort_order>
|
162 |
+
<show_in_default>1</show_in_default>
|
163 |
+
<show_in_website>1</show_in_website>
|
164 |
+
<show_in_store>1</show_in_store>
|
165 |
+
</processstatus>
|
166 |
+
<acknowledgetatus translate="label">
|
167 |
+
<label>Acknowledge Status</label>
|
168 |
+
<comment>
|
169 |
+
<![CDATA[Update order status upon DCL order acknowledgment.]]>
|
170 |
+
</comment>
|
171 |
+
<frontend_type>select</frontend_type>
|
172 |
+
<source_model>dcl_fulfillment/system_config_source_acknowledgestatus</source_model>
|
173 |
+
<sort_order>17</sort_order>
|
174 |
+
<show_in_default>1</show_in_default>
|
175 |
+
<show_in_website>1</show_in_website>
|
176 |
+
<show_in_store>1</show_in_store>
|
177 |
+
</acknowledgetatus>
|
178 |
+
<importdays translate="label">
|
179 |
+
<label>Import Days</label>
|
180 |
+
<comment>
|
181 |
+
<![CDATA[DCL will import orders only on these selected days.]]>
|
182 |
+
</comment>
|
183 |
+
<frontend_type>multiselect</frontend_type>
|
184 |
+
<source_model>dcl_fulfillment/system_config_source_days</source_model>
|
185 |
+
<sort_order>18</sort_order>
|
186 |
+
<show_in_default>1</show_in_default>
|
187 |
+
<show_in_website>1</show_in_website>
|
188 |
+
<show_in_store>1</show_in_store>
|
189 |
+
</importdays>
|
190 |
+
<importtimefrom translate="label">
|
191 |
+
<label>Import Time From (PST)</label>
|
192 |
+
<frontend_type>time</frontend_type>
|
193 |
+
<sort_order>19</sort_order>
|
194 |
+
<show_in_default>1</show_in_default>
|
195 |
+
<show_in_website>1</show_in_website>
|
196 |
+
<show_in_store>1</show_in_store>
|
197 |
+
</importtimefrom>
|
198 |
+
<importtimeto translate="label">
|
199 |
+
<label>Import Time To (PST)</label>
|
200 |
+
<comment>
|
201 |
+
<![CDATA[DCL will import orders only in this range of time.]]>
|
202 |
+
</comment>
|
203 |
+
<frontend_type>time</frontend_type>
|
204 |
+
<sort_order>20</sort_order>
|
205 |
+
<show_in_default>1</show_in_default>
|
206 |
+
<show_in_website>1</show_in_website>
|
207 |
+
<show_in_store>1</show_in_store>
|
208 |
+
</importtimeto>
|
209 |
+
<ordertime translate="label">
|
210 |
+
<label>Order Age</label>
|
211 |
+
<comment>
|
212 |
+
<![CDATA[Time allowed for customer changes before order is transferred to DCL.]]>
|
213 |
+
</comment>
|
214 |
+
<frontend_type>select</frontend_type>
|
215 |
+
<source_model>dcl_fulfillment/system_config_source_orderage</source_model>
|
216 |
+
<sort_order>21</sort_order>
|
217 |
+
<show_in_default>1</show_in_default>
|
218 |
+
<show_in_website>1</show_in_website>
|
219 |
+
<show_in_store>1</show_in_store>
|
220 |
+
</ordertime>
|
221 |
+
</fields>
|
222 |
+
</general>
|
223 |
+
<shipping translate="label" module="dcl_fulfillment">
|
224 |
+
<label>Shipping methods</label>
|
225 |
+
<tab>dcl_fulfillment_tab</tab>
|
226 |
+
<sort_order>1</sort_order>
|
227 |
+
<show_in_default>1</show_in_default>
|
228 |
+
<show_in_website>1</show_in_website>
|
229 |
+
<show_in_store>1</show_in_store>
|
230 |
+
<expanded>1</expanded>
|
231 |
+
<comment><![CDATA[
|
232 |
+
Map all active Magento shipping methods with <a href="https://api.dclcorp.com/Help/ShipMethods" target="_blank">DCL Carrier/Service</a>.<br />
|
233 |
+
<br /><hr /><br />
|
234 |
+
]]>
|
235 |
+
</comment>
|
236 |
+
<fields>
|
237 |
+
<shippingtable translate="label" module="dcl_fulfillment">
|
238 |
+
<label>Mapped Shipping Methods</label>
|
239 |
+
<frontend_model>dcl_fulfillment/adminhtml_config_form_field_shippingtable</frontend_model>
|
240 |
+
<backend_model>adminhtml/system_config_backend_serialized_array</backend_model>
|
241 |
+
<sort_order>2</sort_order>
|
242 |
+
<show_in_default>1</show_in_default>
|
243 |
+
<show_in_website>0</show_in_website>
|
244 |
+
<show_in_store>0</show_in_store>
|
245 |
+
</shippingtable>
|
246 |
+
</fields>
|
247 |
+
</shipping>
|
248 |
+
</groups>
|
249 |
+
</dcl_fulfillment>
|
250 |
+
</sections>
|
251 |
+
</config>
|
app/code/community/DCL/Fulfillment/sql/dcl_fulfillment_setup/install-1.0.0.php
ADDED
@@ -0,0 +1,113 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Installation script
|
5 |
+
*
|
6 |
+
* @author DCL
|
7 |
+
*/
|
8 |
+
|
9 |
+
$installer = $this;
|
10 |
+
|
11 |
+
$installer->startSetup();
|
12 |
+
|
13 |
+
$tableName = $installer->getTable('dcl_fulfillment/acknowledgedorder');
|
14 |
+
if ($installer->getConnection()->isTableExists($tableName) != true) {
|
15 |
+
$table = $installer->getConnection()
|
16 |
+
->newTable($installer->getTable('dcl_fulfillment/acknowledgedorder'))
|
17 |
+
->addColumn('entity_id', Varien_Db_Ddl_Table::TYPE_INTEGER, null, array(
|
18 |
+
'unsigned' => true,
|
19 |
+
'identity' => true,
|
20 |
+
'nullable' => false,
|
21 |
+
'primary' => true,
|
22 |
+
), 'Entity id')
|
23 |
+
->addColumn('order_id', Varien_Db_Ddl_Table::TYPE_INTEGER, null, array(
|
24 |
+
'unsigned' => true,
|
25 |
+
'identity' => false,
|
26 |
+
'nullable' => false,
|
27 |
+
), 'Order id')
|
28 |
+
->addColumn('acknowledged_at', Varien_Db_Ddl_Table::TYPE_TIMESTAMP, null, array(
|
29 |
+
'nullable' => true,
|
30 |
+
), 'Acknowledge Time')
|
31 |
+
->addColumn('modified_at', Varien_Db_Ddl_Table::TYPE_TIMESTAMP, null, array(
|
32 |
+
'nullable' => true,
|
33 |
+
), 'Modified At')
|
34 |
+
->addColumn('stage', Varien_Db_Ddl_Table::TYPE_INTEGER, null, array(
|
35 |
+
'nullable' => true,
|
36 |
+
), 'Stage')
|
37 |
+
->addColumn('stage_description', Varien_Db_Ddl_Table::TYPE_TEXT, 40, array(
|
38 |
+
'nullable' => true,
|
39 |
+
), 'Stage Description')
|
40 |
+
->addIndex($installer->getIdxName(
|
41 |
+
$installer->getTable('dcl_fulfillment/acknowledgedorder'),
|
42 |
+
array('order_id'),
|
43 |
+
Varien_Db_Adapter_Interface::INDEX_TYPE_UNIQUE
|
44 |
+
),
|
45 |
+
array('order_id'),
|
46 |
+
array('type' => Varien_Db_Adapter_Interface::INDEX_TYPE_UNIQUE)
|
47 |
+
)
|
48 |
+
// Speed up order grid (filter by DCL order stage)
|
49 |
+
->addIndex($installer->getIdxName(
|
50 |
+
$installer->getTable('dcl_fulfillment/acknowledgedorder'),
|
51 |
+
array('stage_description'),
|
52 |
+
Varien_Db_Adapter_Interface::INDEX_TYPE_UNIQUE
|
53 |
+
),
|
54 |
+
array('stage_description'),
|
55 |
+
array('type' => Varien_Db_Adapter_Interface::INDEX_TYPE_INDEX)
|
56 |
+
)
|
57 |
+
->setComment('DCL Acknowledged Orders');
|
58 |
+
|
59 |
+
$installer->getConnection()->createTable($table);
|
60 |
+
}
|
61 |
+
|
62 |
+
$tableName = $installer->getTable('dcl_fulfillment/inventory');
|
63 |
+
if ($installer->getConnection()->isTableExists($tableName) != true) {
|
64 |
+
$table = $installer->getConnection()
|
65 |
+
->newTable($installer->getTable('dcl_fulfillment/inventory'))
|
66 |
+
->addColumn('entity_id', Varien_Db_Ddl_Table::TYPE_INTEGER, null, array(
|
67 |
+
'unsigned' => true,
|
68 |
+
'identity' => true,
|
69 |
+
'nullable' => false,
|
70 |
+
'primary' => true,
|
71 |
+
), 'Entity id')
|
72 |
+
->addColumn('sku', Varien_Db_Ddl_Table::TYPE_TEXT, 64, array(
|
73 |
+
'identity' => false,
|
74 |
+
'nullable' => false,
|
75 |
+
), 'SKU')
|
76 |
+
->addColumn('qty', Varien_Db_Ddl_Table::TYPE_INTEGER, null, array(
|
77 |
+
'nullable' => true,
|
78 |
+
), 'Qty')
|
79 |
+
->addColumn('modified_at', Varien_Db_Ddl_Table::TYPE_TIMESTAMP, null, array(
|
80 |
+
'nullable' => true,
|
81 |
+
), 'Modified At')
|
82 |
+
->addIndex($installer->getIdxName(
|
83 |
+
$installer->getTable('dcl_fulfillment/inventory'),
|
84 |
+
array('sku'),
|
85 |
+
Varien_Db_Adapter_Interface::INDEX_TYPE_UNIQUE
|
86 |
+
),
|
87 |
+
array('sku'),
|
88 |
+
array('type' => Varien_Db_Adapter_Interface::INDEX_TYPE_UNIQUE)
|
89 |
+
)
|
90 |
+
->setComment('DCL Inventory');
|
91 |
+
|
92 |
+
$installer->getConnection()->createTable($table);
|
93 |
+
}
|
94 |
+
|
95 |
+
$install_version = Mage::getConfig()->getModuleConfig('DCL_Fulfillment')->version;
|
96 |
+
|
97 |
+
$msg_title = "DCL Fulfillment {$install_version} was successfully installed! Remember to flush all cache, log-out and log back in.";
|
98 |
+
$msg_desc = "DCL Fulfillment {$install_version} was successfully installed on your store. "
|
99 |
+
. "Remember to flush all cache, log-out and log back in. "
|
100 |
+
. "You can configure DCL Fulfillment in the Configuration section.";
|
101 |
+
$message = Mage::getModel('adminnotification/inbox');
|
102 |
+
$message->setDateAdded(date("c", time()));
|
103 |
+
|
104 |
+
$message->setSeverity(Mage_AdminNotification_Model_Inbox::SEVERITY_NOTICE);
|
105 |
+
|
106 |
+
$message->setTitle($msg_title);
|
107 |
+
$message->setDescription($msg_desc);
|
108 |
+
$message->setUrl("#");
|
109 |
+
$message->save();
|
110 |
+
|
111 |
+
$installer->endSetup();
|
112 |
+
|
113 |
+
?>
|
app/design/adminhtml/default/default/layout/dcl_fulfillment.xml
ADDED
@@ -0,0 +1,36 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<!--
|
3 |
+
/**
|
4 |
+
* Magento backend layout
|
5 |
+
*
|
6 |
+
* @author DCL
|
7 |
+
*/
|
8 |
+
-->
|
9 |
+
<layout>
|
10 |
+
<!-- main layout definition that adds the column -->
|
11 |
+
<add_order_grid_column_handle>
|
12 |
+
<reference name="sales_order.grid">
|
13 |
+
<action method="addColumnAfter">
|
14 |
+
<columnId>stage_description</columnId>
|
15 |
+
<arguments translate="label" module="dcl_fulfillment">
|
16 |
+
<header>DCL Order Stage</header>
|
17 |
+
<index>stage_description</index>
|
18 |
+
<filter_index>ack_order.stage_description</filter_index>
|
19 |
+
<type>text</type>
|
20 |
+
<width>150</width>
|
21 |
+
</arguments>
|
22 |
+
<after>grand_total</after>
|
23 |
+
</action>
|
24 |
+
</reference>
|
25 |
+
</add_order_grid_column_handle>
|
26 |
+
<!-- order grid action -->
|
27 |
+
<adminhtml_sales_order_grid>
|
28 |
+
<!-- apply the layout handle defined above -->
|
29 |
+
<update handle="add_order_grid_column_handle" />
|
30 |
+
</adminhtml_sales_order_grid>
|
31 |
+
<!-- order grid view action -->
|
32 |
+
<adminhtml_sales_order_index>
|
33 |
+
<!-- apply the layout handle defined above -->
|
34 |
+
<update handle="add_order_grid_column_handle" />
|
35 |
+
</adminhtml_sales_order_index>
|
36 |
+
</layout>
|
app/design/adminhtml/default/default/template/dcl/array.phtml
ADDED
@@ -0,0 +1,155 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Magento
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the Academic Free License (AFL 3.0)
|
8 |
+
* that is bundled with this package in the file LICENSE_AFL.txt.
|
9 |
+
* It is also available through the world-wide-web at this URL:
|
10 |
+
* http://opensource.org/licenses/afl-3.0.php
|
11 |
+
* If you did not receive a copy of the license and are unable to
|
12 |
+
* obtain it through the world-wide-web, please send an email
|
13 |
+
* to license@magento.com so we can send you a copy immediately.
|
14 |
+
*
|
15 |
+
* DISCLAIMER
|
16 |
+
*
|
17 |
+
* Do not edit or add to this file if you wish to upgrade Magento to newer
|
18 |
+
* versions in the future. If you wish to customize Magento for your
|
19 |
+
* needs please refer to http://www.magento.com for more information.
|
20 |
+
*
|
21 |
+
* @category design
|
22 |
+
* @package default_default
|
23 |
+
* @copyright Copyright (c) 2006-2014 X.commerce, Inc. (http://www.magento.com)
|
24 |
+
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
|
25 |
+
*/
|
26 |
+
?>
|
27 |
+
|
28 |
+
<?php
|
29 |
+
$_htmlId = $this->getHtmlId() ? $this->getHtmlId() : '_' . uniqid();
|
30 |
+
|
31 |
+
$_colspan = 2;
|
32 |
+
if (!$this->_addAfter) {
|
33 |
+
$_colspan -= 1;
|
34 |
+
}
|
35 |
+
$_colspan = $_colspan > 1 ? 'colspan="' . $_colspan . '"' : '';
|
36 |
+
?>
|
37 |
+
|
38 |
+
<div class="grid" id="grid<?php echo $_htmlId ?>">
|
39 |
+
<table cellpadding="0" cellspacing="0" class="border">
|
40 |
+
<tbody>
|
41 |
+
|
42 |
+
<tr class="headings" id="headings<?php echo $_htmlId ?>">
|
43 |
+
<?php foreach ($this->_columns as $columnName => $column):?>
|
44 |
+
<th><?php echo $column['label'] ?></th>
|
45 |
+
<?php endforeach;?>
|
46 |
+
<th <?php echo $_colspan?> style="display:none"></th>
|
47 |
+
</tr>
|
48 |
+
|
49 |
+
<tr id="addRow<?php echo $_htmlId ?>">
|
50 |
+
<td colspan="<?php echo count($this->_columns) ?>"></td>
|
51 |
+
<td <?php echo $_colspan?> style="display:none">
|
52 |
+
<button style="display:none" onclick="" class="scalable add" type="button" id="addToEndBtn<?php echo $_htmlId ?>">
|
53 |
+
<span><span><span><?php echo $this->_addButtonLabel ?></span></span></span>
|
54 |
+
</button>
|
55 |
+
</td>
|
56 |
+
</tr>
|
57 |
+
|
58 |
+
</tbody>
|
59 |
+
</table>
|
60 |
+
<input type="hidden" name="<?php echo $this->getElement()->getName() ?>[__empty]" value="" />
|
61 |
+
</div>
|
62 |
+
|
63 |
+
<script type="text/javascript">
|
64 |
+
//<![CDATA[
|
65 |
+
// create row creator
|
66 |
+
var arrayRow<?php echo $_htmlId ?> = {
|
67 |
+
// define row prototypeJS template
|
68 |
+
template : new Template(
|
69 |
+
'<tr id="#{_id}">'
|
70 |
+
<?php foreach ($this->_columns as $columnName => $column):?>
|
71 |
+
+'<td>'
|
72 |
+
+'<?php echo $this->_renderCellTemplate($columnName)?>'
|
73 |
+
+'<\/td>'
|
74 |
+
<?php endforeach;?>
|
75 |
+
+'<\/tr>'
|
76 |
+
),
|
77 |
+
|
78 |
+
rowsCount : 0,
|
79 |
+
|
80 |
+
add : function(templateData, insertAfterId)
|
81 |
+
{
|
82 |
+
// generate default template data
|
83 |
+
if ('' == templateData) {
|
84 |
+
var d = new Date();
|
85 |
+
var templateData = {
|
86 |
+
<?php foreach ($this->_columns as $columnName => $column):?>
|
87 |
+
<?php echo $columnName ?> : '',
|
88 |
+
<?php endforeach;?>
|
89 |
+
_id : '_' + d.getTime() + '_' + d.getMilliseconds()
|
90 |
+
};
|
91 |
+
}
|
92 |
+
|
93 |
+
// insert before last row
|
94 |
+
if ('' == insertAfterId) {
|
95 |
+
Element.insert($('addRow<?php echo $_htmlId ?>'), {before: this.template.evaluate(templateData)});
|
96 |
+
}
|
97 |
+
// insert after specified row
|
98 |
+
else {
|
99 |
+
Element.insert($(insertAfterId), {after: this.template.evaluate(templateData)});
|
100 |
+
}
|
101 |
+
|
102 |
+
<?php if ($this->_addAfter):?>
|
103 |
+
Event.observe('addAfterBtn' + templateData._id, 'click', this.add.bind(this, '', templateData._id));
|
104 |
+
<?php endif;?>
|
105 |
+
|
106 |
+
this.rowsCount += 1;
|
107 |
+
},
|
108 |
+
|
109 |
+
del : function(rowId)
|
110 |
+
{
|
111 |
+
$(rowId).remove();
|
112 |
+
this.rowsCount -= 1;
|
113 |
+
if (0 == this.rowsCount) {
|
114 |
+
this.showButtonOnly();
|
115 |
+
}
|
116 |
+
},
|
117 |
+
|
118 |
+
showButtonOnly : function()
|
119 |
+
{
|
120 |
+
$('grid<?php echo $_htmlId ?>').hide();
|
121 |
+
$('empty<?php echo $_htmlId ?>').show();
|
122 |
+
}
|
123 |
+
}
|
124 |
+
|
125 |
+
// bind add action to "Add" button in last row
|
126 |
+
Event.observe('addToEndBtn<?php echo $_htmlId ?>', 'click', arrayRow<?php echo $_htmlId ?>.add.bind(arrayRow<?php echo $_htmlId ?>, '', ''));
|
127 |
+
|
128 |
+
// add existing rows
|
129 |
+
<?php
|
130 |
+
$_addAfterId = "headings{$_htmlId}";
|
131 |
+
foreach ($this->getArrayRows() as $_rowId => $_row) {
|
132 |
+
echo "arrayRow{$_htmlId}.add(" . $_row->toJson() . ", '{$_addAfterId}');\n";
|
133 |
+
$_addAfterId = $_rowId;
|
134 |
+
}
|
135 |
+
?>
|
136 |
+
|
137 |
+
// initialize standalone button
|
138 |
+
$('empty<?php echo $_htmlId ?>').hide();
|
139 |
+
Event.observe('emptyAddBtn<?php echo $_htmlId ?>', 'click', function () {
|
140 |
+
$('grid<?php echo $_htmlId ?>').show();
|
141 |
+
$('empty<?php echo $_htmlId ?>').hide();
|
142 |
+
arrayRow<?php echo $_htmlId ?>.add('', '');
|
143 |
+
});
|
144 |
+
|
145 |
+
// if no rows, hide grid and show button only
|
146 |
+
<?php if (!$this->getArrayRows()):?>
|
147 |
+
arrayRow<?php echo $_htmlId ?>.showButtonOnly();
|
148 |
+
<?php endif;?>
|
149 |
+
|
150 |
+
// toggle the grid, if element is disabled (depending on scope)
|
151 |
+
<?php if ($this->getElement()->getDisabled()):?>
|
152 |
+
toggleValueElements({checked:true}, $('grid<?php echo $_htmlId ?>').parentNode);
|
153 |
+
<?php endif;?>
|
154 |
+
//]]>
|
155 |
+
</script>
|
app/design/adminhtml/default/default/template/dcl/link_button.phtml
ADDED
@@ -0,0 +1,76 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<script type="text/javascript">
|
2 |
+
//<![CDATA[
|
3 |
+
function linkToEFactory(efactory_username, efactory_password, account_number, link_label, unlink_label, store_url, store_id) {
|
4 |
+
var params = {
|
5 |
+
efactory_username: efactory_username,
|
6 |
+
efactory_password: efactory_password,
|
7 |
+
account_number: account_number,
|
8 |
+
link_label: link_label,
|
9 |
+
unlink_label: unlink_label,
|
10 |
+
store_url: store_url,
|
11 |
+
store_id: store_id
|
12 |
+
};
|
13 |
+
|
14 |
+
new Ajax.Request('<?php echo $this->getAjaxLinkUrl() ?>', {
|
15 |
+
method: 'post',
|
16 |
+
parameters : { data: JSON.stringify(params),
|
17 |
+
form_key: "<?php echo Mage::getSingleton('core/session')->getFormKey();?>"
|
18 |
+
},
|
19 |
+
onSuccess: function(response) {
|
20 |
+
/*if(response.ajaxExpired && response.ajaxRedirect) {
|
21 |
+
setLocation(response.ajaxRedirect);
|
22 |
+
return;
|
23 |
+
}*/
|
24 |
+
if (response.status == 200) {
|
25 |
+
var result = JSON && JSON.parse(response.responseText) || $.parseJSON(response.responseText);
|
26 |
+
if (result.error_code != 0) {
|
27 |
+
var html = '<ul class="messages"><li class="error-msg"><ul><li>' + result.error_message + '</li></ul></li></ul>';
|
28 |
+
$('messages').update(html);
|
29 |
+
}
|
30 |
+
else {
|
31 |
+
$('messages').update('');
|
32 |
+
//location.reload(); // Too slow
|
33 |
+
if (result.account_number != null && result.account_number.length != 0) {
|
34 |
+
// If just linked, disable fields and set account number and button label
|
35 |
+
document.getElementById('dcl_fulfillment_general_account_number').value = result.account_number;
|
36 |
+
var style = "border: 0; color:#494; background-color:transparent;";
|
37 |
+
document.getElementById('dcl_fulfillment_general_efactory_username').style.cssText = style;
|
38 |
+
document.getElementById('dcl_fulfillment_general_efactory_password').style.cssText = style;
|
39 |
+
|
40 |
+
document.getElementById('dcl_fulfillment_link').title = params.unlink_label;
|
41 |
+
$nodes = document.getElementById('dcl_fulfillment_link').childNodes[0];
|
42 |
+
while ($nodes.innerText == '') {
|
43 |
+
$nodes = $nodes.childNodes[0];
|
44 |
+
}
|
45 |
+
$nodes.innerText = params.unlink_label;
|
46 |
+
}
|
47 |
+
else {
|
48 |
+
// If just un-linked, enable fields and reset account number and button label
|
49 |
+
document.getElementById('dcl_fulfillment_general_account_number').value = "";
|
50 |
+
document.getElementById('dcl_fulfillment_general_efactory_username').style.cssText = "";
|
51 |
+
document.getElementById('dcl_fulfillment_general_efactory_password').style.cssText = "";
|
52 |
+
document.getElementById('dcl_fulfillment_general_efactory_username').disabled = false;
|
53 |
+
document.getElementById('dcl_fulfillment_general_efactory_password').disabled = false;
|
54 |
+
document.getElementById('dcl_fulfillment_general_efactory_username').value = "";
|
55 |
+
document.getElementById('dcl_fulfillment_general_efactory_password').value = "";
|
56 |
+
|
57 |
+
document.getElementById('dcl_fulfillment_link').title = params.link_label;
|
58 |
+
$nodes = document.getElementById('dcl_fulfillment_link').childNodes[0];
|
59 |
+
while ($nodes.innerText == '') {
|
60 |
+
$nodes = $nodes.childNodes[0];
|
61 |
+
}
|
62 |
+
$nodes.innerText = params.link_label;
|
63 |
+
}
|
64 |
+
}
|
65 |
+
}
|
66 |
+
},
|
67 |
+
onFailure: function(response){
|
68 |
+
setLocation('/admin');
|
69 |
+
//alert("Call is failed" );
|
70 |
+
}
|
71 |
+
});
|
72 |
+
}
|
73 |
+
//]]>
|
74 |
+
</script>
|
75 |
+
|
76 |
+
<?php echo $this->getButtonHtml() ?>
|
app/etc/modules/DCL_Fulfillment.xml
ADDED
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<!--
|
3 |
+
/**
|
4 |
+
* Module initial config
|
5 |
+
*
|
6 |
+
* DCL Fulfillment extension
|
7 |
+
*
|
8 |
+
* @author DCL
|
9 |
+
*
|
10 |
+
*/
|
11 |
+
-->
|
12 |
+
<config>
|
13 |
+
<modules>
|
14 |
+
<DCL_Fulfillment>
|
15 |
+
<active>true</active>
|
16 |
+
<codePool>community</codePool>
|
17 |
+
<depends>
|
18 |
+
<Mage_Adminhtml />
|
19 |
+
</depends>
|
20 |
+
</DCL_Fulfillment>
|
21 |
+
</modules>
|
22 |
+
</config>
|
package.xml
ADDED
@@ -0,0 +1,19 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<package>
|
3 |
+
<name>DCL_Fulfillment</name>
|
4 |
+
<version>1.0.0</version>
|
5 |
+
<stability>stable</stability>
|
6 |
+
<license uri="http://en.wikipedia.org/wiki/Open_Software_License">OSL</license>
|
7 |
+
<channel>community</channel>
|
8 |
+
<extends/>
|
9 |
+
<summary>Linking your Magento store to DCL fulfillment warehouses seamlessly.</summary>
|
10 |
+
<description>The Extension provides a simple page in System / Configuration section that allows a Magento administrator to easily choose the options for the particular store and be seamlessly integrated with the DCL system. The orders will automatically flow to DCL system and DCL will seamlessly update order status and inventory stock levels within the Magento site. 
|
11 |
+
The selection and timing for orders to be fulfilled by DCL can be based on a simple or a sophisticated criteria using multiple variables. And since the Extension supports multiple stores, each store can be set up to have its own criteria. The addition of a column to the Magento Sales Order grid itself to show a real time status of the order in the shipping process provides Magento administrator a significant benefit with store management. The Extension also utilizes a sophisticated approach with the latest technology to significantly reduce the calls between the systems, decreasing the bandwidth and the server time process and significantly improving performance for high order volume stores.</description>
|
12 |
+
<notes>Initial release.</notes>
|
13 |
+
<authors><author><name>Discopylabs</name><user>Discopylabs</user><email>sales@dclcorp.com</email></author></authors>
|
14 |
+
<date>2015-04-18</date>
|
15 |
+
<time>05:15:40</time>
|
16 |
+
<contents><target name="magecommunity"><dir name="DCL"><dir name="Fulfillment"><dir name="Block"><dir name="Adminhtml"><dir name="Config"><dir name="Form"><file name="Accountnumber.php" hash="8a4071d265e0def7501dd5516aec9524"/><dir name="Field"><file name="Shippingtable.php" hash="cff3a5604fc4512fbd289d4eacd669a6"/></dir><file name="Link.php" hash="6a5255552e246dd32fd2ea1495c8234f"/><file name="Readonlyconditionalfield.php" hash="71c300738d83eac2a8d0f80b46d15f8b"/></dir></dir></dir></dir><dir name="Helper"><file name="Admin.php" hash="401a569f2eff5360569beb0fa407c1a4"/><file name="Data.php" hash="b1ffda6332c173042d16ca564831cdec"/></dir><dir name="Model"><file name="Acknowledgedorder.php" hash="587977f0a50735894d63a64155cc0b7a"/><file name="Inventory.php" hash="d51806d9e83e8c825f41e3bda96d33c4"/><file name="Observer.php" hash="fa7ce59f342c3c5d4344955a8bb7cedb"/><dir name="Resource"><dir name="Acknowledgedorder"><file name="Collection.php" hash="03af8a05c1294989a1468084f51790e9"/></dir><file name="Acknowledgedorder.php" hash="07b942c21edbe454e79a1850da3a3be5"/><dir name="Inventory"><file name="Collection.php" hash="56640ad07115035d207f38d0dc5a3add"/></dir><file name="Inventory.php" hash="50f9b04cf4b9aaebeff8c1caefb277e6"/></dir><dir name="System"><dir name="Config"><dir name="Source"><file name="Acknowledgestatus.php" hash="703db4ad34ecec939e9019b376b1c6d3"/><file name="Days.php" hash="17906aaf18cab79170a880412a107350"/><file name="Orderage.php" hash="78b5f4790db4391198e9f06168db093d"/><file name="Statuslist.php" hash="07aea2fe17d1669f6821fd4efc285921"/></dir></dir></dir></dir><dir name="controllers"><file name="ApiController.php" hash="4f0340c4358000cb230385af9561ca64"/><file name="RegisterController.php" hash="5afbdf81f59e0b8e49e255e3d7031b84"/></dir><dir name="etc"><file name="adminhtml.xml" hash="e86eda8442b803e3bcf6bdf36e4bb01b"/><file name="config.xml" hash="4f91dbd334f363b7747c7eb89d2f8014"/><file name="system.xml" hash="c34ed8a7e8deb6441c035681eb45a1d6"/></dir><dir name="sql"><dir name="dcl_fulfillment_setup"><file name="install-1.0.0.php" hash="4da7d4d3b4b055221c9a03369e92d38a"/></dir></dir></dir></dir></target><target name="mageskin"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="images"><file name="dcl_fulfillment_logo.png" hash="b151e62f51ec5c24d201a1c461e23ef2"/></dir></dir></dir></dir></target><target name="magedesign"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="template"><dir name="dcl"><file name="array.phtml" hash="cc825279242115a8a4f22df95b491da8"/><file name="link_button.phtml" hash="a1f8d2aefce64e8eebea6521a7f7802e"/></dir></dir><dir name="layout"><file name="dcl_fulfillment.xml" hash="e7fc4fbcfd6173c7f692450fee609c57"/></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="DCL_Fulfillment.xml" hash="69f65c05c6559e1bfbd128665071b5f2"/></dir></target></contents>
|
17 |
+
<compatible/>
|
18 |
+
<dependencies><required><php><min>5.2.0</min><max>6.0.0</max></php></required></dependencies>
|
19 |
+
</package>
|
skin/adminhtml/default/default/images/dcl_fulfillment_logo.png
ADDED
Binary file
|