Sendabox_Sendabox - Version 1.0.0

Version Notes

Version number: 1.0.0 Stability: Stable

Download this release

Release Info

Developer Italmondo S.p.a.
Extension Sendabox_Sendabox
Version 1.0.0
Comparing to
See all releases


Version 1.0.0

Files changed (50) hide show
  1. CityOrigin.php +29 -0
  2. app/code/community/Sendabox/Sendabox/Block/Adminhtml/Shipment.php +15 -0
  3. app/code/community/Sendabox/Sendabox/Block/Adminhtml/Shipment/Edit.php +123 -0
  4. app/code/community/Sendabox/Sendabox/Block/Adminhtml/Shipment/Edit/Form.php +22 -0
  5. app/code/community/Sendabox/Sendabox/Block/Adminhtml/Shipment/Edit/Tab/Abstract.php +64 -0
  6. app/code/community/Sendabox/Sendabox/Block/Adminhtml/Shipment/Edit/Tab/Form.php +36 -0
  7. app/code/community/Sendabox/Sendabox/Block/Adminhtml/Shipment/Edit/Tab/Form/Anywhere.php +8 -0
  8. app/code/community/Sendabox/Sendabox/Block/Adminhtml/Shipment/Edit/Tab/Form/Boxes.php +8 -0
  9. app/code/community/Sendabox/Sendabox/Block/Adminhtml/Shipment/Edit/Tab/Form/Products.php +18 -0
  10. app/code/community/Sendabox/Sendabox/Block/Adminhtml/Shipment/Edit/Tab/Form/Quotes.php +50 -0
  11. app/code/community/Sendabox/Sendabox/Block/Adminhtml/Shipment/Edit/Tab/Form/Status.php +27 -0
  12. app/code/community/Sendabox/Sendabox/Block/Adminhtml/Shipment/Edit/Tabs.php +14 -0
  13. app/code/community/Sendabox/Sendabox/Block/Adminhtml/Shipment/Grid.php +115 -0
  14. app/code/community/Sendabox/Sendabox/Block/Adminhtml/System/Config/Form/Field/Required.php +47 -0
  15. app/code/community/Sendabox/Sendabox/Block/Adminhtml/System/Config/Form/Fieldset/General.php +24 -0
  16. app/code/community/Sendabox/Sendabox/Helper/Data.php +247 -0
  17. app/code/community/Sendabox/Sendabox/Model/Box.php +35 -0
  18. app/code/community/Sendabox/Sendabox/Model/Carrier.php +54 -0
  19. app/code/community/Sendabox/Sendabox/Model/Observer.php +226 -0
  20. app/code/community/Sendabox/Sendabox/Model/Quote.php +80 -0
  21. app/code/community/Sendabox/Sendabox/Model/Resource/Box.php +11 -0
  22. app/code/community/Sendabox/Sendabox/Model/Resource/Box/Collection.php +12 -0
  23. app/code/community/Sendabox/Sendabox/Model/Resource/Carrier.php +11 -0
  24. app/code/community/Sendabox/Sendabox/Model/Resource/Carrier/Collection.php +12 -0
  25. app/code/community/Sendabox/Sendabox/Model/Resource/Quote.php +11 -0
  26. app/code/community/Sendabox/Sendabox/Model/Resource/Quote/Collection.php +74 -0
  27. app/code/community/Sendabox/Sendabox/Model/Resource/Shipment.php +11 -0
  28. app/code/community/Sendabox/Sendabox/Model/Resource/Shipment/Collection.php +29 -0
  29. app/code/community/Sendabox/Sendabox/Model/Shipment.php +230 -0
  30. app/code/community/Sendabox/Sendabox/Model/Shipping/Carrier/Sendabox.php +320 -0
  31. app/code/community/Sendabox/Sendabox/Model/Shipping/Carrier/Sendabox/Source/Method.php +74 -0
  32. app/code/community/Sendabox/Sendabox/Model/System/Config/Backend/Form/Field/Required/Text.php +17 -0
  33. app/code/community/Sendabox/Sendabox/Model/System/Config/Source.php +82 -0
  34. app/code/community/Sendabox/Sendabox/Model/System/Config/Source/Errorprocess.php +17 -0
  35. app/code/community/Sendabox/Sendabox/Model/System/Config/Source/Insurance.php +19 -0
  36. app/code/community/Sendabox/Sendabox/Model/System/Config/Source/Pricing.php +21 -0
  37. app/code/community/Sendabox/Sendabox/Model/System/Config/Source/Shipment/Status.php +17 -0
  38. app/code/community/Sendabox/Sendabox/Model/System/Config/Source/Unit.php +56 -0
  39. app/code/community/Sendabox/Sendabox/Model/System/Config/Source/Unit/Measure.php +28 -0
  40. app/code/community/Sendabox/Sendabox/Model/System/Config/Source/Unit/Weight.php +28 -0
  41. app/code/community/Sendabox/Sendabox/controllers/Adminhtml/ShipmentController.php +260 -0
  42. app/code/community/Sendabox/Sendabox/etc/adminhtml.xml +73 -0
  43. app/code/community/Sendabox/Sendabox/etc/config.xml +168 -0
  44. app/code/community/Sendabox/Sendabox/etc/system.xml +476 -0
  45. app/code/community/Sendabox/Sendabox/sql/sendabox_sendabox_setup/mysql4-install-1.0.0.php +205 -0
  46. app/design/adminhtml/default/default/layout/sendabox.xml +36 -0
  47. app/etc/modules/Sendabox_Sendabox.xml +19 -0
  48. js/sendabox/autocomplete.js +7 -0
  49. package.xml +23 -0
  50. skin/adminhtml/default/default/sendabox/sendabox.css +22 -0
CityOrigin.php ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ $destination_city = $_REQUEST['destination_city'];
3
+ if(isset($destination_city)){
4
+ $destination_city = str_replace(" ", "%20", $destination_city);
5
+ $url = 'http://www.sendabox.it/_magento/get/city?q=' .$destination_city;
6
+ $html = file_get_contents($url);
7
+ if ($html) {
8
+ $chiamata = json_decode($html, true);
9
+ if(!is_array($chiamata)) { $chiamata = array($chiamata); }
10
+ if(isset($chiamata['error']) && $chiamata['error']){
11
+ //echo $chiamata['msg'];
12
+ return;
13
+ }
14
+ else {
15
+ if(count($chiamata)==0) return;
16
+ echo "<ul>" ;
17
+ foreach($chiamata as $suggest){
18
+ $city = explode('-',$suggest['label'])[0];
19
+ $id= $suggest['id'];
20
+ echo "<li id='$id'>$city</li>";
21
+ }
22
+ echo "</ul>" ;
23
+ }
24
+ } else {
25
+ //echo 'ERRORE CHIAMATA';
26
+ return;
27
+ }
28
+ }
29
+ ?>
app/code/community/Sendabox/Sendabox/Block/Adminhtml/Shipment.php ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Sendabox_Sendabox_Block_Adminhtml_Shipment extends Mage_Adminhtml_Block_Widget_Grid_Container
4
+ {
5
+
6
+ public function __construct()
7
+ {
8
+ $this->_blockGroup = 'sendabox_sendabox';
9
+ $this->_controller = 'adminhtml_shipment';
10
+ $this->_headerText = Mage::helper('sendabox_sendabox')->__('Manage Shipments');
11
+ parent::__construct();
12
+ $this->removeButton('add');
13
+ }
14
+
15
+ }
app/code/community/Sendabox/Sendabox/Block/Adminhtml/Shipment/Edit.php ADDED
@@ -0,0 +1,123 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Sendabox_Sendabox_Block_Adminhtml_Shipment_Edit extends Mage_Adminhtml_Block_Widget_Form_Container
4
+ {
5
+
6
+ protected $_shipment;
7
+
8
+ public function __construct()
9
+ {
10
+ parent::__construct();
11
+ $this->_blockGroup = 'sendabox_sendabox';
12
+ $this->_controller = 'adminhtml_shipment';
13
+
14
+ $this->removeButton('save');
15
+ $this->removeButton('delete');
16
+
17
+ $add_button_method = 'addButton';
18
+ if (!method_exists($this, $add_button_method)) {
19
+ $add_button_method = '_addButton';
20
+ }
21
+
22
+ if ($this->getShipment()->getStatus() == Sendabox_Sendabox_Model_System_Config_Source_Shipment_Status::PENDING) {
23
+ $this->$add_button_method('getquote', array(
24
+ 'label' => Mage::helper('sendabox_sendabox')->__('Save and Get Quotes'),
25
+ 'id' => 'getquote',
26
+ 'onclick' => 'saveAndGetQuotes()',
27
+ 'value' => '',
28
+ 'class' => 'save',
29
+ ));
30
+ }
31
+
32
+
33
+ $max_boxes = 40;
34
+ $script = "
35
+ function saveAndGetQuotes() {
36
+ editForm.submit($('edit_form').action+'and/getquotes/');
37
+ }
38
+
39
+ function box_add() {
40
+ num_boxes = $$('table#boxes tbody tr').length - 1;
41
+ if (num_boxes < $max_boxes) {
42
+ if (!box_add.highest_num) {
43
+ box_add.highest_num = num_boxes;
44
+ }
45
+ // add a new box (row) to the table
46
+ new_row = new Element('tr');
47
+ new_row.id = 'box_row_' + ++box_add.highest_num;
48
+ new_row
49
+ .addClassName(box_add.highest_num % 2 ? 'odd' : 'even')
50
+ .addClassName('new_box')
51
+ .insert($('blank_box_row').innerHTML
52
+ .replace(/@@id@@/g, box_add.highest_num)
53
+ .replace(/box_blank/g, 'box'));
54
+
55
+ $$('table#boxes tbody')[0].insert(new_row);
56
+ return box_add.highest_num;
57
+ } else {
58
+ return false;
59
+ }
60
+ }
61
+
62
+ function box_clear() {
63
+ // remove all rows in the table.
64
+ $$('table#boxes tr.existing_box, table#boxes tr.new_box').each(function (row) {
65
+ row.remove();
66
+ });
67
+ }
68
+
69
+ function box_remove(num) {
70
+ row = $('box_row_' + num);
71
+ if ($('box_' + num + '_id') && $('boxes_deleted')) {
72
+ if (!$('boxes_deleted').value.length == 0) {
73
+ $('boxes_deleted').value += ',';
74
+ }
75
+ $('boxes_deleted').value += $('box_' + num + '_id').value;
76
+ }
77
+ if (row) {
78
+ row.remove();
79
+ }
80
+ }
81
+ ";
82
+
83
+ $this->_formScripts[] = $script;
84
+ }
85
+
86
+ /**
87
+ * Gets the shipment being edited.
88
+ *
89
+ * @return Sendabox_Sendabox_Model_Shipment
90
+ */
91
+ public function getShipment()
92
+ {
93
+ if (!$this->_shipment) {
94
+ $this->_shipment = Mage::registry('sendabox_shipment_data');
95
+ }
96
+ return $this->_shipment;
97
+ }
98
+
99
+ /**
100
+ * Gets the current order for the shipment being edited.
101
+ *
102
+ * @return Mage_Sales_Model_Order
103
+ */
104
+ public function getOrder()
105
+ {
106
+ if($this->getShipment()) {
107
+ return $this->getShipment()->getOrder();
108
+ }
109
+ return null;
110
+ }
111
+
112
+ public function getHeaderText()
113
+ {
114
+ if ($this->getShipment() && $this->getShipment()->getId()) {
115
+ return $foo= Mage::helper('sendabox_sendabox')->__(
116
+ 'Order # %s | %s',
117
+ $this->htmlEscape($this->getShipment()->getOrder()->getRealOrderId()),
118
+ $this->htmlEscape($this->formatDate($this->getShipment()->getOrder()->getCreatedAtDate(), 'medium', true))
119
+ );
120
+ }
121
+ }
122
+
123
+ }
app/code/community/Sendabox/Sendabox/Block/Adminhtml/Shipment/Edit/Form.php ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Sendabox_Sendabox_Block_Adminhtml_Shipment_Edit_Form extends Mage_Adminhtml_Block_Widget_Form
4
+ {
5
+
6
+ protected function _prepareForm()
7
+ {
8
+ $form = new Varien_Data_Form(
9
+ array(
10
+ 'id' => 'edit_form',
11
+ 'action' => $this->getUrl('*/*/save', array('id' => $this->getRequest()->getParam('id'))),
12
+ 'method' => 'post',
13
+ 'enctype' => 'multipart/form-data'
14
+ )
15
+ );
16
+
17
+ $form->setUseContainer(true);
18
+ $this->setForm($form);
19
+ return parent::_prepareForm();
20
+ }
21
+
22
+ }
app/code/community/Sendabox/Sendabox/Block/Adminhtml/Shipment/Edit/Tab/Abstract.php ADDED
@@ -0,0 +1,64 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ abstract class Sendabox_Sendabox_Block_Adminhtml_Shipment_Edit_Tab_Abstract extends Mage_Adminhtml_Block_Template
4
+ {
5
+
6
+ protected $_helper = null;
7
+
8
+ public function __construct()
9
+ {
10
+ parent::__construct();
11
+ $this->setParentBlock(Mage::getBlockSingleton('sendabox_sendabox/adminhtml_shipment_edit'));
12
+ }
13
+
14
+ /**
15
+ * Gets the shipment being edited.
16
+ *
17
+ * @return Sendabox_Sendabox_Model_Shipment
18
+ */
19
+ public function getShipment()
20
+ {
21
+ return $this->getParentBlock()->getShipment();
22
+ }
23
+
24
+ /**
25
+ * Gets the saved Sendabox quotes for this order from the database.
26
+ *
27
+ * @return Sendabox_Sendabox_Model_Mysql4_Quote_Collection
28
+ */
29
+ public function getQuotes()
30
+ {
31
+ return $this->getShipment()->getQuotes(true);
32
+ }
33
+
34
+ public function formatCurrency($price)
35
+ {
36
+ return Mage::helper('core')->currency($price);
37
+ }
38
+
39
+ public function getWeightUnitText($unit = null)
40
+ {
41
+ if (!$unit) {
42
+ $unit = $this->getSendaboxHelper()->getConfigData('units/weight');
43
+ }
44
+ return Mage::getModel('sendabox_sendabox/system_config_source_unit_weight')
45
+ ->getBriefOptionLabel($unit);
46
+ }
47
+
48
+ public function getMeasureUnitText($unit = null)
49
+ {
50
+ if (!$unit) {
51
+ $unit = $this->getSendaboxHelper()->getConfigData('units/measure');
52
+ }
53
+ return Mage::getModel('sendabox_sendabox/system_config_source_unit_measure')
54
+ ->getBriefOptionLabel($unit);
55
+ }
56
+
57
+ public function getSendaboxHelper() {
58
+ if (!$this->_helper) {
59
+ $this->_helper = Mage::helper('sendabox_sendabox');
60
+ }
61
+ return $this->_helper;
62
+ }
63
+
64
+ }
app/code/community/Sendabox/Sendabox/Block/Adminhtml/Shipment/Edit/Tab/Form.php ADDED
@@ -0,0 +1,36 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Sendabox_Sendabox_Block_Adminhtml_Shipment_Edit_Tab_Form
4
+ extends Sendabox_Sendabox_Block_Adminhtml_Shipment_Edit_Tab_Abstract
5
+ implements Mage_Adminhtml_Block_Widget_Tab_Interface
6
+ {
7
+
8
+ protected $_template = 'sendabox/sendabox/shipment.phtml';
9
+
10
+ public function __construct()
11
+ {
12
+ parent::__construct();
13
+ $this->setTemplate($this->_template);
14
+ }
15
+
16
+ public function getTabLabel()
17
+ {
18
+ return $this->__('Information');
19
+ }
20
+
21
+ public function getTabTitle()
22
+ {
23
+ return $this->__('Information');
24
+ }
25
+
26
+ public function canShowTab()
27
+ {
28
+ return true;
29
+ }
30
+
31
+ public function isHidden()
32
+ {
33
+ return false;
34
+ }
35
+
36
+ }
app/code/community/Sendabox/Sendabox/Block/Adminhtml/Shipment/Edit/Tab/Form/Anywhere.php ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Sendabox_Sendabox_Block_Adminhtml_Shipment_Edit_Tab_Form_Anywhere extends Sendabox_Sendabox_Block_Adminhtml_Shipment_Edit_Tab_Abstract
4
+ {
5
+
6
+
7
+
8
+ }
app/code/community/Sendabox/Sendabox/Block/Adminhtml/Shipment/Edit/Tab/Form/Boxes.php ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Sendabox_Sendabox_Block_Adminhtml_Shipment_Edit_Tab_Form_Boxes extends Sendabox_Sendabox_Block_Adminhtml_Shipment_Edit_Tab_Abstract
4
+ {
5
+
6
+
7
+
8
+ }
app/code/community/Sendabox/Sendabox/Block/Adminhtml/Shipment/Edit/Tab/Form/Products.php ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Sendabox_Sendabox_Block_Adminhtml_Shipment_Edit_Tab_Form_Products extends Sendabox_Sendabox_Block_Adminhtml_Shipment_Edit_Tab_Abstract
4
+ {
5
+
6
+ /**
7
+ * Gets a Magento catalog product belonging to a Magento order item.
8
+ *
9
+ * @param Mage_Sales_Model_Order_Item $item the Magento order item
10
+ *
11
+ * @return Mage_Catalog_Model_Product
12
+ */
13
+ public function getProductFromItem(Mage_Sales_Model_Order_Item $item)
14
+ {
15
+ return Mage::getModel('catalog/product')->load($item->getProductId());
16
+ }
17
+
18
+ }
app/code/community/Sendabox/Sendabox/Block/Adminhtml/Shipment/Edit/Tab/Form/Quotes.php ADDED
@@ -0,0 +1,50 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Sendabox_Sendabox_Block_Adminhtml_Shipment_Edit_Tab_Form_Quotes extends Sendabox_Sendabox_Block_Adminhtml_Shipment_Edit_Tab_Abstract
4
+ {
5
+
6
+ protected $_cheapest_quote_id;
7
+ protected $_customer_selected_quote_id;
8
+
9
+ public function __construct() {
10
+ parent::__construct();
11
+ if (($quotes = $this->getQuotes()->load())) {
12
+ if(($cheapest_quote = $quotes->getCheapest())) {
13
+ $this->_cheapest_quote_id = $cheapest_quote->getId();
14
+ }
15
+ }
16
+
17
+ if ($this->getShipment()) {
18
+ $this->_customer_selected_quote_id = $this->getShipment()->getCustomerSelectedQuoteId();
19
+ }
20
+ }
21
+
22
+ public function formatQuotePrice(Sendabox_Sendabox_Model_Quote $quote)
23
+ {
24
+ return $this->formatCurrency($quote->getTotalPrice());
25
+ /*$quote->getCurrency() . ' ' .
26
+ $this->formatCurrency($quote->getTotalPrice()) .
27
+ ' (inc. ' .
28
+ $this->formatCurrency($quote->getTax()) .
29
+ ' tax)';*/
30
+ }
31
+
32
+ public function getQuoteNotes(Sendabox_Sendabox_Model_Quote $quote)
33
+ {
34
+ $text = '';
35
+
36
+ if ($this->_cheapest_quote_id == $quote->getId()) {
37
+ $text .= 'Cheapest';
38
+ }
39
+
40
+ if ($this->_customer_selected_quote_id == $quote->getId()) {
41
+ if ($text) {
42
+ $text .= ', ';
43
+ }
44
+ $text .= 'Customer Selected';
45
+ }
46
+
47
+ return $text;
48
+ }
49
+
50
+ }
app/code/community/Sendabox/Sendabox/Block/Adminhtml/Shipment/Edit/Tab/Form/Status.php ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Sendabox_Sendabox_Block_Adminhtml_Shipment_Edit_Tab_Form_Status extends Sendabox_Sendabox_Block_Adminhtml_Shipment_Edit_Tab_Abstract
4
+ {
5
+ /**
6
+ * @var Sendabox_Sendabox_Model_Quote
7
+ */
8
+ protected $_customer_selected_quote = null;
9
+
10
+ /**
11
+ * Gets the description of the Sendabox quote selected by the customer.
12
+ *
13
+ * @return TSendabox_Sendabox_Model_Quote
14
+ */
15
+ public function getCustomerSelectedQuoteDescription()
16
+ {
17
+ return $this->getShipment()->getCustomerSelectedQuoteDescription();
18
+ }
19
+
20
+
21
+ public function getShipmentStatusText()
22
+ {
23
+ return Mage::getModel('sendabox_sendabox/system_config_source_shipment_status')
24
+ ->getOptionLabel($this->getShipment()->getStatus());
25
+ }
26
+
27
+ }
app/code/community/Sendabox/Sendabox/Block/Adminhtml/Shipment/Edit/Tabs.php ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Sendabox_Sendabox_Block_Adminhtml_Shipment_Edit_Tabs extends Mage_Adminhtml_Block_Widget_Tabs
4
+ {
5
+
6
+ public function __construct()
7
+ {
8
+ parent::__construct();
9
+ $this->setId('sendabox_shipment_edit_tabs');
10
+ $this->setDestElementId('edit_form');
11
+ $this->setTitle(Mage::helper('sendabox_sendabox')->__('Shipment View'));
12
+ }
13
+
14
+ }
app/code/community/Sendabox/Sendabox/Block/Adminhtml/Shipment/Grid.php ADDED
@@ -0,0 +1,115 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Sendabox_Sendabox_Block_Adminhtml_Shipment_Grid extends Mage_Adminhtml_Block_Widget_Grid
4
+ {
5
+
6
+ public function __construct()
7
+ {
8
+ parent::__construct();
9
+ $this->setSaveParametersInSession(true);
10
+ }
11
+
12
+ protected function _prepareLayout() {
13
+ parent::_prepareLayout();
14
+ return $this;
15
+ }
16
+
17
+ public function getMainButtonsHtml() {
18
+ $html = '';
19
+ if ($this->getFilterVisibility()) {
20
+ $html.= $this->getResetFilterButtonHtml();
21
+ $html.= $this->getSearchButtonHtml();
22
+ }
23
+ return $html;
24
+ }
25
+
26
+ protected function _prepareCollection()
27
+ {
28
+ $collection = Mage::getModel('sendabox_sendabox/shipment')->getCollection();
29
+ $collection->join('sales/order', 'main_table.order_id=`sales/order`.entity_id', array('increment_id', 'created_at', 'shipping_amount'));
30
+ /* @var $collection Sendabox_Sendabox_Model_Shipment */
31
+
32
+ $collection->getSelect()->order(array(
33
+ 'main_table.status ASC',
34
+ 'created_at DESC'
35
+ ));
36
+
37
+ $this->setCollection($collection);
38
+ return parent::_prepareCollection();
39
+ }
40
+
41
+ protected function _prepareColumns()
42
+ {
43
+ $this->addColumn('order_number', array(
44
+ 'header' => Mage::helper('sendabox_sendabox')->__('Order #'),
45
+ 'width' => '100px',
46
+ 'index' => 'increment_id',
47
+ ));
48
+
49
+ $this->addColumn('created_at', array(
50
+ 'header' => Mage::helper('sendabox_sendabox')->__('Purchased On'),
51
+ 'width' => '160px',
52
+ 'type' => 'datetime',
53
+ 'index' => 'created_at',
54
+ 'filter_index' => '`sales/order`.created_at',
55
+ ));
56
+
57
+ $this->addColumn('status', array(
58
+ 'header' => Mage::helper('sendabox_sendabox')->__('Status'),
59
+ 'index' => 'status',
60
+ 'type' => 'options',
61
+ 'width' => '100px',
62
+ 'options' => Mage::getSingleton('sendabox_sendabox/system_config_source_shipment_status')->getOptions(),
63
+ 'filter_index' => 'main_table.status',
64
+ ));
65
+
66
+ $this->addColumn('anticipated_cost', array(
67
+ 'header' => Mage::helper('sendabox_sendabox')->__('Anticipated Cost'),
68
+ 'align' => 'left',
69
+ 'type' => 'currency',
70
+ 'currency_code' => Mage::app()->getStore()->getCurrentCurrencyCode(),
71
+ 'index' => 'shipping_amount',
72
+ ));
73
+
74
+ $this->addColumn('shipping_paid', array(
75
+ 'header' => Mage::helper('sendabox_sendabox')->__('Shipping Paid'),
76
+ 'align' => 'left',
77
+ 'type' => 'currency',
78
+ 'currency_code' => Mage::app()->getStore()->getCurrentCurrencyCode(),
79
+ 'index' => 'customer_cost',
80
+ ));
81
+
82
+ $this->addColumn('selected_quote_description', array(
83
+ 'header' => Mage::helper('sendabox_sendabox')->__('Customer Selected Quote'),
84
+ 'align' => 'left',
85
+ 'index' => 'customer_selected_quote_description',
86
+ ));
87
+
88
+ $this->addColumn('action', array(
89
+ 'header' => Mage::helper('sendabox_sendabox')->__('Action'),
90
+ 'width' => '100',
91
+ 'type' => 'action',
92
+ 'getter' => 'getId',
93
+ 'actions' => array(
94
+ 'view' => array(
95
+ 'caption' => Mage::helper('sendabox_sendabox')->__('View'),
96
+ 'url' => array('base' => '*/*/edit'),
97
+ 'field' => 'id'
98
+ )
99
+ ),
100
+ 'filter' => false,
101
+ 'sortable' => false,
102
+ 'index' => 'stores',
103
+ 'is_system' => true,
104
+ ));
105
+
106
+ return parent::_prepareColumns();
107
+ }
108
+
109
+
110
+ public function getRowUrl($row)
111
+ {
112
+ return $this->getUrl('*/*/edit', array('id' => $row->getId()));
113
+ }
114
+
115
+ }
app/code/community/Sendabox/Sendabox/Block/Adminhtml/System/Config/Form/Field/Required.php ADDED
@@ -0,0 +1,47 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Sendabox_Sendabox_Block_Adminhtml_System_Config_Form_Field_Required extends Mage_Adminhtml_Block_System_Config_Form_Field
4
+ {
5
+
6
+ protected $_element;
7
+
8
+ /**
9
+ * (non-PHPdoc)
10
+ * @see Mage_Adminhtml_Block_System_Config_Form_Field::render()
11
+ *
12
+ * Adds the "required" star to the form field.
13
+ */
14
+ public function render(Varien_Data_Form_Element_Abstract $element)
15
+ {
16
+ $this->_element = $element;
17
+ $html = parent::render($this->_element);
18
+
19
+ $html = $this->_addStar($html);
20
+ $html = $this->_addRequiredClass($html);
21
+
22
+ return $html;
23
+ }
24
+
25
+ protected function _addStar($html)
26
+ {
27
+ $search = '<label for="' . $this->_element->getHtmlId() . '">' . $this->_element->getLabel() . '</label>';
28
+ $replacement = '<label for="' . $this->_element->getHtmlId() . '">' . $this->_element->getLabel() . ' <span class="required">*</span></label>';
29
+
30
+ return str_replace($search, $replacement, $html);
31
+ }
32
+
33
+ protected function _addRequiredClass($html)
34
+ {
35
+ $search = array(
36
+ '#(<input.*class=")([^<>"]*)(".*>)#',
37
+ '#(<select.*class=")([^<>"]*)(".*>)#',
38
+ );
39
+ $replacement = array(
40
+ '$1required-entry $2$3',
41
+ '$1validate-select $2$3',
42
+ );
43
+
44
+ return preg_replace($search, $replacement, $html);
45
+ }
46
+
47
+ }
app/code/community/Sendabox/Sendabox/Block/Adminhtml/System/Config/Form/Fieldset/General.php ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Sendabox_Sendabox_Block_Adminhtml_System_Config_Form_Fieldset_General extends Mage_Adminhtml_Block_System_Config_Form_Fieldset
4
+ {
5
+
6
+ /**
7
+ * @see Mage_Adminhtml_Block_System_Config_Form_Fieldset::_getHeaderHtml()
8
+ *
9
+ * Passes the output text through a basic replacement function to find
10
+ * instances of "{{store url="..."}}" and replace these with the correct
11
+ * Magento URLs.
12
+ */
13
+ protected function _getHeaderHtml($element)
14
+ {
15
+ $html = parent::_getHeaderHtml($element);
16
+ $pattern = '#{{store url="(.*?)"}}#';
17
+
18
+ return preg_replace_callback($pattern, create_function('$elements', '
19
+ // $elements[1] is the 1st parenthesized expression
20
+ return Mage::getModel("adminhtml/url")->getUrl($elements[1]);
21
+ '), $html);
22
+ }
23
+
24
+ }
app/code/community/Sendabox/Sendabox/Helper/Data.php ADDED
@@ -0,0 +1,247 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Sendabox_Sendabox_Helper_Data extends Mage_Core_Helper_Abstract {
4
+
5
+ const DEFAULT_WAREHOUSE_NAME = 'Magento Warehouse';
6
+
7
+ private $_sendaboxAttributes = array(
8
+ 'sendabox_length',
9
+ 'sendabox_width',
10
+ 'sendabox_height'
11
+ );
12
+
13
+ protected $_allowedCountries = array(
14
+ 'IT' => 'Italia',
15
+ );
16
+
17
+ /**
18
+ * Retrieves an element from the module configuration data.
19
+ *
20
+ * @param string $field
21
+ */
22
+ public function getConfigData($field) {
23
+ $path = 'sendabox_options/' . $field;
24
+ return Mage::getStoreConfig($path);
25
+ }
26
+
27
+ /**
28
+ * Returns array of allowed countries based on Magento system configuration
29
+ * and Sendabox plugin allowed countries.
30
+ *
31
+ * @return array
32
+ */
33
+ public function getAllowedCountries() {
34
+ $specific = Mage::getStoreConfig('carriers/sendabox_sendabox/sallowspecific');
35
+ //check if all allowed and return selected
36
+ if($specific == 1) {
37
+ $availableCountries = explode(',', Mage::getStoreConfig('carriers/sendabox_sendabox/specificcountry'));
38
+ $countries = array_intersect_key($this->_allowedCountries, array_flip($availableCountries));
39
+ return $countries;
40
+ }
41
+ //return all allowed
42
+ return $this->_allowedCountries;
43
+ }
44
+
45
+
46
+
47
+ /**
48
+ * Retrieve Default Sendabox Product Attributes from Configuration
49
+ *
50
+ * @return array
51
+ */
52
+ public function getDefaultSendaboxAttributes()
53
+ {
54
+ return array(
55
+
56
+ 'sendabox_length' => (float)$this->getConfigData('defaults/length'),
57
+ 'sendabox_width' => (float)$this->getConfigData('defaults/width'),
58
+ 'senadbox_height' => (float)$this->getConfigData('defaults/height'),
59
+ );
60
+ }
61
+
62
+ /**
63
+ * Converts given weight from configured unit to grams
64
+ *
65
+ * @param float $value Weight to convert
66
+ * @param string $currentUnit Current weight unit
67
+ * @return float Converted weight in grams
68
+ */
69
+ public function getWeightInKGrams($value, $currentUnit = null)
70
+ {
71
+ $value = floatval($value);
72
+ $currentUnit = $currentUnit ? $currentUnit : $this->getConfigData('units/weight');
73
+ //from units as specified in configuration
74
+ switch($currentUnit) {
75
+
76
+ case Sendabox_Sendabox_Model_System_Config_Source_Unit_Weight::OUNCES:
77
+ return $value * 28.3495; break;
78
+
79
+ case Sendabox_Sendabox_Model_System_Config_Source_Unit_Weight::POUNDS:
80
+ return $value * 453.592; break;
81
+
82
+ default: return $value; break;
83
+ }
84
+ }
85
+
86
+ /**
87
+ * Converts given distance from configured unit to centimetres
88
+ *
89
+ * @param float $value Distance to convert
90
+ * @param string $currentUnit Current measure unit
91
+ * @return float Converted distance in centimetres
92
+ */
93
+ public function getDistanceInCentimetres($value, $currentUnit = null)
94
+ {
95
+ $value = floatval($value);
96
+ $currentUnit = $currentUnit ? $currentUnit : $this->getConfigData('units/measure');
97
+ switch($currentUnit) {
98
+
99
+ case Sendabox_Sendabox_Model_System_Config_Source_Unit_Measure::FEET:
100
+ return $value * 30.48; break;
101
+
102
+ case Sendabox_Sendabox_Model_System_Config_Source_Unit_Measure::INCHES:
103
+ return $value * 2.54; break;
104
+
105
+ default: return $value; break;
106
+ }
107
+ }
108
+
109
+
110
+
111
+
112
+
113
+ /**
114
+ * Returns region name saved in customers session
115
+ * @return string|null
116
+ */
117
+ public function getSessionRegion() {
118
+ $data = Mage::getSingleton('customer/session')->getData('estimate_product_shipping');
119
+ if ($data) {
120
+ return Mage::getModel('directory/region')->load($data['region_id'])->getName();
121
+ }
122
+
123
+ return null;
124
+ }
125
+
126
+ /**
127
+ * Returns city name saved in customers session
128
+ * @return string|null
129
+ */
130
+ public function getSessionCity() {
131
+ $data = Mage::getSingleton('customer/session')->getData('estimate_product_shipping');
132
+ if ($data) {
133
+ return $data['city'];
134
+ }
135
+
136
+ return null;
137
+ }
138
+
139
+ /**
140
+ * Returns postal code saved in customers session
141
+ * @return string|null
142
+ */
143
+ public function getSessionPostcode() {
144
+ $data = Mage::getSingleton('customer/session')->getData('estimate_product_shipping');
145
+ if ($data) {
146
+ return $data['postcode'];
147
+ }
148
+
149
+ return null;
150
+ }
151
+
152
+ /**
153
+ * Returns id of the region saved in customers session
154
+ * @return int|null
155
+ */
156
+ public function getSessionRegionId() {
157
+ $data = Mage::getSingleton('customer/session')->getData('estimate_product_shipping');
158
+ if ($data) {
159
+ return $data['region_id'];
160
+ }
161
+
162
+ return null;
163
+ }
164
+
165
+ /**
166
+ * Return list of available origin locations
167
+ *
168
+ * @return array
169
+ */
170
+ public function getLocationList() {
171
+ return array(
172
+ self::DEFAULT_WAREHOUSE_NAME => self::DEFAULT_WAREHOUSE_NAME
173
+ );
174
+ }
175
+
176
+ /**
177
+ * Returns location create/update request array
178
+ *
179
+ * @return array
180
+ */
181
+ public function getOriginRequestArray(Varien_Object $data) {
182
+ return array(
183
+ 'description' => self::DEFAULT_WAREHOUSE_NAME,
184
+ 'type' => 'Origin',
185
+ 'contactName' => $data->getContactName(),
186
+ 'companyName' => $data->getCompanyName(),
187
+ 'street' => $data->getStreet(),
188
+ 'suburb' => $data->getCity(),
189
+ 'state' => $data->getRegion(),
190
+ 'code' => $data->getPostcode(),
191
+ 'country' => $data->getCountry(),
192
+ 'phone1' => $data->getPhone1(),
193
+ 'phone2' => $data->getPhone2(),
194
+ 'fax' => $data->getFax(),
195
+ 'email' => $data->getEmail(),
196
+ 'loadingFacilities' => $data->getLoadingFacilities() ? 'Y' : 'N',
197
+ 'forklift' => $data->getForklift() ? 'Y' : 'N',
198
+ 'dock' => $data->getDock() ? 'Y' : 'N',
199
+ 'limitedAccess' => $data->getLimitedAccess() ? 'Y' : 'N',
200
+ 'postalBox' => $data->getPobox() ? 'Y' : 'N'
201
+ );
202
+ }
203
+
204
+
205
+ /**
206
+ * Returns true if shipping quote is dynamic quote
207
+ *
208
+ * @param int $quote_id
209
+ * @return boolean
210
+ */
211
+ public function isQuoteDynamic($quote_id) {
212
+ $fixed_carriers = array(
213
+ Sendabox_Sendabox_Model_Carrier::FLAT_RATE,
214
+ Sendabox_Sendabox_Model_Carrier::FREE,
215
+ );
216
+
217
+ if (in_array($quote_id, $fixed_carriers)) {
218
+ return false;
219
+ }
220
+
221
+ return true;
222
+ }
223
+
224
+
225
+ public function getCheapestQuote($quotes)
226
+ {
227
+ $cheapest = null;
228
+ foreach ($quotes as $quote) {
229
+ $cheapest = $this->_getCheaper($quote, $cheapest);
230
+ }
231
+ return $cheapest;
232
+ }
233
+
234
+ protected function _getCheaper($a, $b)
235
+ {
236
+ // if one is null, return the other (if both are null, null is returned).
237
+ if (is_null($a)) {
238
+ return $b;
239
+ }
240
+ if (is_null($b)) {
241
+ return $a;
242
+ }
243
+
244
+ return $a->getTotalPrice() <= $b->getTotalPrice() ? $a : $b;
245
+ }
246
+
247
+ }
app/code/community/Sendabox/Sendabox/Model/Box.php ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * @method string getShipmentId()
5
+ * @method string getComment()
6
+ * @method string getQty()
7
+ * @method string getLength()
8
+ * @method string getWidth()
9
+ * @method string getHeight()
10
+ * @method string getMeasureUnit()
11
+ * @method string getWeight()
12
+ * @method string getWeightUnit()
13
+ * @method string getFragile()
14
+ *
15
+ * @method Temando_Temando_Model_Box setShipmentId()
16
+ * @method Temando_Temando_Model_Box setComment()
17
+ * @method Temando_Temando_Model_Box setQty()
18
+ * @method Temando_Temando_Model_Box setLength()
19
+ * @method Temando_Temando_Model_Box setWidth()
20
+ * @method Temando_Temando_Model_Box setHeight()
21
+ * @method Temando_Temando_Model_Box setMeasureUnit()
22
+ * @method Temando_Temando_Model_Box setWeight()
23
+ * @method Temando_Temando_Model_Box setWeightUnit()
24
+ * @method Temando_Temando_Model_Box setFragile()
25
+ */
26
+ class Sendabox_Sendabox_Model_Box extends Mage_Core_Model_Abstract
27
+ {
28
+
29
+ public function _construct()
30
+ {
31
+ parent::_construct();
32
+ $this->_init('sendabox_sendabox/box');
33
+ }
34
+
35
+ }
app/code/community/Sendabox/Sendabox/Model/Carrier.php ADDED
@@ -0,0 +1,54 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * @method Temando_Temando_Model_Carrier setCarrierId()
5
+ * @method Temando_Temando_Model_Carrier setCompanyName()
6
+ * @method Temando_Temando_Model_Carrier setCompanyContact()
7
+ * @method Temando_Temando_Model_Carrier setStreetAddress()
8
+ * @method Temando_Temando_Model_Carrier setStreetSuburb()
9
+ * @method Temando_Temando_Model_Carrier setStreetCity()
10
+ * @method Temando_Temando_Model_Carrier setStreetState()
11
+ * @method Temando_Temando_Model_Carrier setStreetPostode()
12
+ * @method Temando_Temando_Model_Carrier setStreetCountry()
13
+ * @method Temando_Temando_Model_Carrier setPostalAddress()
14
+ * @method Temando_Temando_Model_Carrier setPostalSuburb()
15
+ * @method Temando_Temando_Model_Carrier setPostalCity()
16
+ * @method Temando_Temando_Model_Carrier setPostalState()
17
+ * @method Temando_Temando_Model_Carrier setPostalPostcode()
18
+ * @method Temando_Temando_Model_Carrier setPostalCountry()
19
+ * @method Temando_Temando_Model_Carrier setPhone()
20
+ * @method Temando_Temando_Model_Carrier setEmail()
21
+ * @method Temando_Temando_Model_Carrier setWebsite()
22
+ *
23
+ * @method string getCarrierId()
24
+ * @method string getCompanyName()
25
+ * @method string getCompanyContact()
26
+ * @method string getStreetAddress()
27
+ * @method string getStreetSuburb()
28
+ * @method string getStreetCity()
29
+ * @method string getStreetState()
30
+ * @method string getStreetPostode()
31
+ * @method string getStreetCountry()
32
+ * @method string getPostalAddress()
33
+ * @method string getPostalSuburb()
34
+ * @method string getPostalCity()
35
+ * @method string getPostalState()
36
+ * @method string getPostalPostcode()
37
+ * @method string getPostalCountry()
38
+ * @method string getPhone()
39
+ * @method string getEmail()
40
+ * @method string getWebsite()
41
+ */
42
+ class Sendabox_Sendabox_Model_Carrier extends Mage_Core_Model_Abstract
43
+ {
44
+
45
+ const FLAT_RATE = 'flat';
46
+ const FREE = 'free';
47
+
48
+ public function _construct()
49
+ {
50
+ parent::_construct();
51
+ $this->_init('sendabox_sendabox/carrier');
52
+ }
53
+
54
+ }
app/code/community/Sendabox/Sendabox/Model/Observer.php ADDED
@@ -0,0 +1,226 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Sendabox_Sendabox_Model_Observer
4
+ {
5
+ /**
6
+ * Magento passes a Varien_Event_Observer object as
7
+ * the first parameter of dispatched events.
8
+ */
9
+ /*public function logSpedito(Varien_Event_Observer $observer)
10
+ {
11
+ // Retrieve the shipment being updated from the event observer
12
+ $shipment = $observer->getEvent()->getShipment();
13
+
14
+ // Write a new line to var/log/product-updates.log
15
+ $order = $shipment->getOrder();
16
+ $id = $order->getId();
17
+ Mage::log(
18
+ "{$id} spedito",
19
+ null,
20
+ 'ordinispediti.log', true
21
+ );
22
+ $items = $order->getAllItems();
23
+ $itemcount=count($items);
24
+ $name=array();
25
+ $unitPrice=array();
26
+ $sku=array();
27
+ $ids=array();
28
+ $qty=array();
29
+ $weight=array();
30
+ $width=array();
31
+ $length=array();
32
+ $height=array();
33
+ Mage::log(
34
+ "{$itemcount} oggetti",
35
+ null,
36
+ 'ordinispediti.log', true
37
+ );
38
+ $i=0;
39
+ foreach ($items as $itemId => $item)
40
+ {
41
+ $name[] = $item->getName();
42
+ $unitPrice[]=$item->getPrice();
43
+ $sku[]=$item->getSku();
44
+ $ids[]=$item->getProductId();
45
+ $qty[]=$item->getQtyToInvoice();
46
+ $weight[]=$item->getWeight();
47
+ $product = Mage::getModel('catalog/product')->load($ids[$i]);
48
+ $width[] = $product->getSendaboxWidth();
49
+ $length[] = $product->getSendaboxLength();
50
+ $height[] = $product->getSendaboxHeight();
51
+ Mage::log(
52
+ "nome: {$name[$i]},prezzo: {$unitPrice[$i]}, sku: {$sku[$i]}, id: {$ids[$i]}, quantità: {$qty[$i]}, peso: {$weight[$i]}, larghezza: {$width[$i]}, lunghezza: {$length[$i]}, altezza: {$height[$i]}",
53
+ null,
54
+ 'ordinispediti.log', true
55
+ );
56
+ $i++;
57
+ }
58
+ }*/
59
+
60
+ /**
61
+ * Handles sales_order_place_after event
62
+ */
63
+ public function createSendaboxShipment(Varien_Event_Observer $observer)
64
+ {
65
+ $order = $observer->getOrder();
66
+ /* @var $order Mage_Sales_Model_Order */
67
+
68
+ if(!array_key_exists($order->getShippingAddress()->getCountryId(), Mage::helper('sendabox_sendabox')->getAllowedCountries()))
69
+ return;
70
+
71
+ $shippingMethod = $order->getShippingMethod();
72
+ $__t = explode('_', $shippingMethod);
73
+ $is_sandabox_quote = ($__t[0] == 'sendabox') ;
74
+
75
+ $selected_quote_id = preg_replace('#^([^_]*_){3}#', '', $shippingMethod);
76
+
77
+ if($is_sandabox_quote)
78
+ {
79
+ $selected_quote = Mage::getModel('sendabox_sendabox/quote')->load($selected_quote_id);
80
+ }
81
+ if(!$is_sandabox_quote or !$selected_quote->getId()) {
82
+ //try loading cheapeast quote
83
+ try {
84
+ $selected_quote = $this->loadCheapestQuote($order);
85
+ /* @var $selected_quote Sendabox_Sendabox_Model_Quote */
86
+ }
87
+ catch (Exception $e)
88
+ {
89
+ $selected_quote = null;
90
+ }
91
+ }
92
+
93
+
94
+
95
+ $sendabox_shipment = Mage::getModel('sendabox_sendabox/shipment');
96
+ /* @var $sendabox_shipment Sendabox_Sendabox_Model_Shipment */
97
+
98
+ if($is_sandabox_quote && Mage::helper('sendabox_sendabox')->isQuoteDynamic($selected_quote_id)) {
99
+ //DYNAMIC: carrier quote selected by customer - must have at least 1 available quote
100
+ $sendabox_shipment
101
+ ->setAdminSelectedQuoteId($selected_quote->getId())
102
+ ->setCustomerSelectedQuoteId($selected_quote->getId());
103
+ $selected_quote = $sendabox_shipment->getSelectedQuote();
104
+ $sendabox_shipment
105
+ ->setCustomerSelectedQuoteDescription($selected_quote->getDescription())
106
+ ->setCustomerCost($selected_quote->getTotalPrice());
107
+ }
108
+ elseif(!$is_sandabox_quote){
109
+ $sendabox_shipment
110
+ ->setCustomerSelectedQuoteDescription($order->getShippingDescription());
111
+
112
+ if($selected_quote instanceof Sendabox_Sendabox_Model_Quote) {
113
+ //set cheapest as admin selected
114
+ $sendabox_shipment->setAdminSelectedQuoteId($selected_quote->getId())
115
+ ->setCustomerCost($selected_quote->getTotalPrice());
116
+ }
117
+ }
118
+ else {
119
+ //STATIC: flat rate / free shipping selected by customer
120
+ $sendabox_shipment
121
+ ->setCustomerSelectedQuoteDescription('Free Shipping');
122
+
123
+ if($selected_quote instanceof Sendabox_Sendabox_Model_Quote) {
124
+ //set cheapest as admin selected
125
+ $sendabox_shipment->setAdminSelectedQuoteId($selected_quote->getId())
126
+ ->setCustomerCost($selected_quote->getTotalPrice());
127
+ }
128
+ }
129
+
130
+ $email = $order->getShippingAddress()->getEmail();
131
+ if(!$email) {
132
+ $email = $order->getCustomerEmail();
133
+ }
134
+
135
+ $sendabox_shipment
136
+ ->setOrderId($order->getId() ? $order->getId() : null)
137
+ ->setStatus(Sendabox_Sendabox_Model_System_Config_Source_Shipment_Status::PENDING)
138
+ ->setDestinationName($order->getShippingAddress()->getFirstname())
139
+ ->setDestinationSurname($order->getShippingAddress()->getLastname())
140
+ ->setDestinationStreet(str_replace("\n", ', ', $order->getShippingAddress()->getStreetFull()))
141
+ ->setDestinationPhone($order->getShippingAddress()->getTelephone())
142
+ ->setDestinationEmail($email)
143
+ ->setDestinationPostcode($order->getShippingAddress()->getPostcode())
144
+ ->setDestinationCity($order->getShippingAddress()->getCity())
145
+ ->save();
146
+
147
+ $weight = 0;
148
+ $comment = '';
149
+ $value = 0;
150
+ foreach ($order->getAllVisibleItems() as $item) {
151
+ $product = Mage::getModel('catalog/product')->load($item->getProductId());
152
+ if($product->isVirtual()) { continue; }
153
+
154
+ /*Mage::helper('sendabox_sendabox')->applySendaboxParamsToItem($item);*/
155
+
156
+ $qty = $item->getQty() ? $item->getQty() : $item->getQtyOrdered();
157
+ $weight += $item->getWeight()*$qty;
158
+ $comment .= " " .$item->getName() ."-";
159
+ $value += $item->getRowTotalInclTax()*$qty;
160
+ }
161
+
162
+ $box = Mage::getModel('sendabox_sendabox/box');
163
+ /* @var $box Sendabox_Sendabox_Model_Box */
164
+ $box
165
+ ->setShipmentId($sendabox_shipment->getId())
166
+ ->setComment($comment)
167
+ ->setQty(1)
168
+ ->setValue($value)
169
+ ->setLength(10)
170
+ ->setWidth(10)
171
+ ->setHeight(10)
172
+ ->setMeasureUnit(Mage::helper('sendabox_sendabox')->getConfigData('units/measure'))
173
+ ->setWeight($weight)
174
+ ->setWeightUnit(Mage::helper('sendabox_sendabox')->getConfigData('units/weight'))
175
+ ->save();
176
+ }
177
+
178
+ public function addJavascriptBlock($observer)
179
+ {
180
+ //exit(__METHOD__);
181
+ $controller = $observer->getAction();
182
+ $layout = $controller->getLayout();
183
+ $block = $layout->createBlock('core/text');
184
+ $credits = $this->getCredits();
185
+ $block->setText(
186
+ "<script type='text/javascript'>
187
+ function main_pulsestorm_hellojavascript()
188
+ {
189
+ var credits = document.getElementById('sendabox_options_general_credits');
190
+ if(credits!=null)
191
+ credits.value = ' {$credits} ';
192
+ }
193
+ main_pulsestorm_hellojavascript();
194
+ </script>"
195
+ );
196
+ $layout->getBlock('js')->append($block);
197
+ }
198
+
199
+ protected function getCredits(){
200
+ $username = Mage::helper('sendabox_sendabox')->getConfigData('general/username');
201
+ $password = Mage::helper('sendabox_sendabox')->getConfigData('general/password');
202
+ $url='http://www.sendabox.it/_magento/get/credits?api_user=' .$username .'&api_secret=' .$password;
203
+ $html = file_get_contents($url);
204
+ if ($html) {
205
+ $chiamata = json_decode($html, true);
206
+ if(isset($chiamata['error']) && $chiamata['error']){
207
+ return 'Sendabox account data not valid';
208
+ } else {
209
+ return $chiamata['credit'];
210
+ }
211
+ } else {
212
+ //exit('not html');
213
+ return 'Sendabox account data not valid';
214
+ }
215
+ }
216
+
217
+ protected function loadCheapestQuote($order)
218
+ {
219
+ $salesQuoteId = $order->getQuoteId();
220
+ $quotes = Mage::getModel('sendabox_sendabox/quote')->getCollection()
221
+ ->addFieldToFilter('magento_quote_id', $salesQuoteId)
222
+ ->getItems();
223
+ if(!is_array($quotes)) { $quotes = array($quotes); }
224
+ return Mage::helper('sendabox_sendabox')->getCheapestQuote($quotes);
225
+ }
226
+ }
app/code/community/Sendabox/Sendabox/Model/Quote.php ADDED
@@ -0,0 +1,80 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Sendabox_Sendabox_Model_Quote extends Mage_Core_Model_Abstract
4
+ {
5
+
6
+ protected $_carrier = null;
7
+
8
+ public function _construct()
9
+ {
10
+ parent::_construct();
11
+ $this->_init('sendabox_sendabox/quote');
12
+ }
13
+
14
+ public function __clone()
15
+ {
16
+ $this->_carrier = clone $this->getCarrier();
17
+ }
18
+
19
+ /**
20
+ * Sets the carrier providing this quote.
21
+ *
22
+ * @param <type> $carrier_id
23
+ *
24
+ * @return Sendabox_Sendabox_Model_Quote
25
+ */
26
+ public function setCarrier($carrier_id)
27
+ {
28
+ $carrier = Mage::getModel('sendabox_sendabox/carrier')
29
+ ->load($carrier_id);
30
+
31
+ if ($carrier->getId() == $carrier_id) {
32
+ // exists in the database
33
+ $this->_carrier = $carrier;
34
+ $this->setData('carrier_id', $carrier_id);
35
+ }
36
+ return $this;
37
+ }
38
+
39
+ /**
40
+ * Gets the carrier providing this quote.
41
+ *
42
+ * @return Sendabox_Sendabox_Model_Carrier
43
+ */
44
+ public function getCarrier()
45
+ {
46
+ if (!$this->_carrier) {
47
+ $this->setCarrier($this->getCarrierId());
48
+ }
49
+ return $this->_carrier;
50
+ }
51
+
52
+
53
+ public function toBookingRequestArray($options)
54
+ {
55
+
56
+
57
+ $request = array(
58
+ 'totalPrice' => $this->getTotalPrice(),
59
+ 'basePrice' => $this->getBasePrice(),
60
+ 'tax' => $this->getTax(),
61
+ 'currency' => $this->getCurrency(),
62
+ 'carrierId' => $this->getCarrier()->getCarrierId(),
63
+ );
64
+
65
+
66
+ return $request;
67
+ }
68
+
69
+
70
+ public function getDescription($showMethod = false)
71
+ {
72
+ $title = '';
73
+ if ($showMethod)
74
+ $title .= $this->getCarrier()->getCompanyName() .' - ';
75
+ $title .= $this->getCommercialName();
76
+
77
+ //return $title . ' ' . $this->getExtraTitle();
78
+ return $title;
79
+ }
80
+ }
app/code/community/Sendabox/Sendabox/Model/Resource/Box.php ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Sendabox_Sendabox_Model_Resource_Box extends Mage_Core_Model_Mysql4_Abstract
4
+ {
5
+
6
+ public function _construct()
7
+ {
8
+ $this->_init('sendabox_sendabox/box', 'id');
9
+ }
10
+
11
+ }
app/code/community/Sendabox/Sendabox/Model/Resource/Box/Collection.php ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Sendabox_Sendabox_Model_Resource_Box_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract
4
+ {
5
+
6
+ public function _construct()
7
+ {
8
+ parent::_construct();
9
+ $this->_init('sendabox_sendabox/box');
10
+ }
11
+
12
+ }
app/code/community/Sendabox/Sendabox/Model/Resource/Carrier.php ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Sendabox_Sendabox_Model_Resource_Carrier extends Mage_Core_Model_Mysql4_Abstract
4
+ {
5
+
6
+ public function _construct()
7
+ {
8
+ $this->_init('sendabox_sendabox/carrier', 'id');
9
+ }
10
+
11
+ }
app/code/community/Sendabox/Sendabox/Model/Resource/Carrier/Collection.php ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Sendabox_Sendabox_Model_Resource_Carrier_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract
4
+ {
5
+
6
+ public function _construct()
7
+ {
8
+ parent::_construct();
9
+ $this->_init('sendabox_sendabox/carrier');
10
+ }
11
+
12
+ }
app/code/community/Sendabox/Sendabox/Model/Resource/Quote.php ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Sendabox_Sendabox_Model_Resource_Quote extends Mage_Core_Model_Mysql4_Abstract
4
+ {
5
+
6
+ public function _construct()
7
+ {
8
+ $this->_init('sendabox_sendabox/quote', 'id');
9
+ }
10
+
11
+ }
app/code/community/Sendabox/Sendabox/Model/Resource/Quote/Collection.php ADDED
@@ -0,0 +1,74 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Sendabox_Sendabox_Model_Resource_Quote_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract
4
+ {
5
+
6
+ protected $_options = null;
7
+
8
+ public function _construct()
9
+ {
10
+ parent::_construct();
11
+ $this->_init('sendabox_sendabox/quote');
12
+ }
13
+
14
+ public function __clone()
15
+ {
16
+ $this->load();
17
+ $new_items = array();
18
+ foreach ($this->_items as $item) {
19
+ $new_items[] = clone $item;
20
+ }
21
+ $this->_items = $new_items;
22
+ }
23
+
24
+
25
+ /**
26
+ * Gets the cheapest quote in the collection.
27
+ *
28
+ * @return Sendabox_Sendabox_Model_Quote
29
+ */
30
+ public function getCheapest()
31
+ {
32
+ $cheapest = null;
33
+ foreach ($this->_items as $item) {
34
+ $cheapest = $this->_getCheaper($item, $cheapest);
35
+ }
36
+ return $cheapest;
37
+ }
38
+
39
+ /**
40
+ * Returns the cheaper of two quotes.
41
+ *
42
+ * If one is null, the other is returned. If both are the same price, the
43
+ * first quote is returned.
44
+ *
45
+ * @param Sendabox_Sendabox_Model_Quote $a the first quote.
46
+ * @param Sendabox_Sendabox_Model_Quote $b the second quote.
47
+ *
48
+ * @return Sendabox_Sendabox_Model_Quote
49
+ */
50
+ protected function _getCheaper($a, $b)
51
+ {
52
+ // if one is null, return the other (if both are null, null is returned).
53
+ if (is_null($a)) {
54
+ return $b;
55
+ }
56
+ if (is_null($b)) {
57
+ return $a;
58
+ }
59
+
60
+ return $a->getTotalPrice() <= $b->getTotalPrice() ? $a : $b;
61
+ }
62
+
63
+ /**
64
+ * Don't try to load the collection if specific items have been added.
65
+ *
66
+ * @see Varien_Data_Collection::addItem()
67
+ */
68
+ public function addItem(Varien_Object $item)
69
+ {
70
+ $this->_setIsLoaded();
71
+ return parent::addItem($item);
72
+ }
73
+
74
+ }
app/code/community/Sendabox/Sendabox/Model/Resource/Shipment.php ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Sendabox_Sendabox_Model_Resource_Shipment extends Mage_Core_Model_Mysql4_Abstract
4
+ {
5
+
6
+ public function _construct()
7
+ {
8
+ $this->_init('sendabox_sendabox/shipment', 'id');
9
+ }
10
+
11
+ }
app/code/community/Sendabox/Sendabox/Model/Resource/Shipment/Collection.php ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Sendabox_Sendabox_Model_Resource_Shipment_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract
4
+ {
5
+
6
+ public function _construct()
7
+ {
8
+ parent::_construct();
9
+ $this->_init('sendabox_sendabox/shipment');
10
+ }
11
+
12
+ /**
13
+ * Returns the shipment associated to an order or null if none
14
+ *
15
+ * NO SUPPORT FOR PARTIAL-SHIPMENTS HERE; ONLY 1 IS RETURNED
16
+ *
17
+ * @param string $orderId
18
+ * @return null|\Sendabox_Sendabox_Model_Shipment
19
+ */
20
+ public function loadByOrderId($orderId) {
21
+ if(!$orderId) return false;
22
+
23
+ $this->addFieldToFilter('order_id', $orderId)->load();
24
+ if($this->count())
25
+ return $this->getFirstItem ();
26
+
27
+ return false;
28
+ }
29
+ }
app/code/community/Sendabox/Sendabox/Model/Shipment.php ADDED
@@ -0,0 +1,230 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * @method int getId()
5
+ * @method int getOrderId()
6
+ * @method string getCustomerSelectedQuoteId()
7
+ * @method string getCustomerSelectedQuoteDescription()
8
+ * @method string getAdminSelectedQuoteId()
9
+ * @method float getAnticipatedCost()
10
+ * @method int getStatus()
11
+ * @method int getBookingRequestId()
12
+ * @method boolean getInsurance()
13
+ * @method string getDestinationCountry()
14
+ * @method string getDestinationPostcode()
15
+ * @method string getDestinationCity()
16
+ * @method string getReadyDate()
17
+ * @method string getReadyTime()
18
+ * @method string getCustomerSelectedOptions()
19
+ * @method string getOrderItems()
20
+ *
21
+ */
22
+ class Sendabox_Sendabox_Model_Shipment extends Mage_Core_Model_Abstract
23
+ {
24
+
25
+ /**
26
+ * @var Mage_Sales_Model_Order
27
+ */
28
+ protected $_order = null;
29
+
30
+ /**
31
+ * @var array
32
+ */
33
+ protected $_boxes = null;
34
+
35
+ public function _construct()
36
+ {
37
+ parent::_construct();
38
+ $this->_init('sendabox_sendabox/shipment');
39
+ }
40
+
41
+ public function getData($key = '', $index = null)
42
+ {
43
+ switch ($key) {
44
+ case 'selected_quote_description': return $this->getSelectedQuoteDescription();
45
+ case 'created_at': return $this->getCreatedAt();
46
+ case 'order_number': return $this->getOrderNumber();
47
+ case 'shipping_paid': return $this->getShippingPaid();
48
+ default:
49
+ }
50
+ return parent::getData($key, $index);
51
+ }
52
+
53
+ /**
54
+ * Gets the Magento order associated with this shipment.
55
+ *
56
+ * @return Mage_Sales_Model_Order
57
+ */
58
+ public function getOrder()
59
+ {
60
+ if (!$this->_order && $this->getId()) {
61
+ $this->_order = Mage::getModel('sales/order')->load($this->getOrderId());
62
+ }
63
+ return $this->_order;
64
+ }
65
+
66
+ /**
67
+ * Gets the creation date of this shipment.
68
+ */
69
+ public function getCreatedAt()
70
+ {
71
+ if ($this->getOrder()) {
72
+ return $this->getOrder()->getCreatedAt();
73
+ }
74
+ return null;
75
+ }
76
+
77
+ /**
78
+ * Gets the Magento order number (as shown to customers, e.g. 100000123)
79
+ */
80
+ public function getOrderNumber()
81
+ {
82
+ if ($this->getOrder()) {
83
+ return $this->getOrder()->getIncrementId();
84
+ }
85
+ return null;
86
+ }
87
+
88
+ public function getBoxes()
89
+ {
90
+ return Mage::getModel('sendabox_sendabox/box')->getCollection()
91
+ ->addFieldToFilter('shipment_id', $this->getId());
92
+ }
93
+
94
+ /**
95
+ * Gets the selected quote.
96
+ *
97
+ * If the Sendabox shipment status is Pending or Cancelled, this will be the
98
+ * quote selected by the user during checkout. If the Sendabox shipment
99
+ * status is Booked, then it will be the booked quote.
100
+ *
101
+ * @return Sendabox_Sendabox_Model_Quote
102
+ */
103
+ public function getSelectedQuote()
104
+ {
105
+ $quote = null;
106
+
107
+ switch ($this->getStatus()) {
108
+ case Sendabox_Sendabox_Model_System_Config_Source_Shipment_Status::BOOKED:
109
+ $quote = Mage::getModel('sendabox_sendabox/quote')
110
+ ->load($this->getAdminSelectedQuoteId());
111
+ break;
112
+ case Sendabox_Sendabox_Model_System_Config_Source_Shipment_Status::PENDING:
113
+ default:
114
+ $quote = Mage::getModel('sendabox_sendabox/quote')
115
+ ->load($this->getCustomerSelectedQuoteId());
116
+ break;
117
+ }
118
+
119
+ return $quote;
120
+ }
121
+
122
+ /**
123
+ * Clears all quotes from the database relating to this shipment.
124
+ */
125
+ public function clearQuotes()
126
+ {
127
+
128
+ $old_quotes = Mage::getModel('sendabox_sendabox/quote')->getCollection()
129
+ ->addFieldToFilter('magento_quote_id', $this->getOrder()->getQuoteId());
130
+ foreach ($old_quotes as $quote) {
131
+ /* @var $quote Sendabox_Sendabox_Model_Quote */
132
+ $quote->delete();
133
+ }
134
+ return $this;
135
+ }
136
+
137
+ public function getQuotes()
138
+ {
139
+ return Mage::getModel('sendabox_sendabox/quote')->getCollection()
140
+ ->addFieldToFilter('magento_quote_id', $this->getOrder()->getQuoteId());
141
+ }
142
+
143
+ public function getNewQuotes(){
144
+ Mage::log(
145
+ "dentro getnewquotes",
146
+ null,
147
+ 'aggiornamento.log', true
148
+ );
149
+ $boxes = $this->getBoxes();
150
+ if(!$boxes) return;
151
+ $i = 1;
152
+ $destination = $this->getDestinationId();
153
+ foreach($boxes as $shipment){
154
+ $i++;
155
+ $weight = $shipment->getWeight();
156
+ $weight = ceil(Mage::helper('sendabox_sendabox')->getWeightInKGrams($weight,$shipment->getWeightUnit()));
157
+ $unit = Mage::helper('sendabox_sendabox')->getConfigData('units/weight');
158
+ Mage::log(
159
+ "{$weight}",
160
+ null,
161
+ 'units.log', true
162
+ );
163
+ $dimensions = '' .ceil(Mage::helper('sendabox_sendabox')->getDistanceInCentimetres($shipment->getWidth(),$shipment->getMeasureUnit())) .',' .ceil(Mage::helper('sendabox_sendabox')->getDistanceInCentimetres($shipment->getHeight(),$shipment->getMeasureUnit())) .',' .ceil(Mage::helper('sendabox_sendabox')->getDistanceInCentimetres($shipment->getLength(),$shipment->getMeasureUnit()));
164
+ Mage::log(
165
+ "dimensioni: {$dimensions}",
166
+ null,
167
+ 'units.log', true
168
+ );
169
+ $destination = $this->getDestinationId();
170
+ $from = Mage::getStoreConfig('sendabox_options/origin/city_id');
171
+ if($destination){
172
+
173
+ $this->createQuotes($from,$destination,$weight,$dimensions,$this->getOrder()->getQuoteId());
174
+ $this->createQuotes($from,$destination,$weight,$dimensions,$this->getOrder()->getQuoteId(),11);
175
+ $this->createQuotes($from,$destination,$weight,$dimensions,$this->getOrder()->getQuoteId(),13);
176
+ }
177
+ }
178
+ $i--;
179
+ foreach($this->getQuotes() as $quote){
180
+ $price = $quote->getTotalPrice();
181
+ $quote->setTotalPrice($price*$i)->save();
182
+ }
183
+ }
184
+
185
+ protected function createQuotes($from= 0, $to= 0, $weight, $dimensions='10,10,10', $salesQuoteId=null,$special=null){
186
+ /*if(!$from || !$to || !$weight)
187
+ return false;*/
188
+ $url='http://www.sendabox.it/_magento/get/prices?from=' .$from .'&to=' .$to .'&weight=' .$weight .'&dimensions=' .$dimensions;
189
+ if($special)
190
+ $url .= '&special=' .$special;
191
+ $html = file_get_contents($url);
192
+ if ($html) {
193
+ $chiamata = json_decode($html, true);
194
+ if(isset($chiamata['error']) && $chiamata['error']){
195
+ //$this->clearQuotes()->save();
196
+ return;
197
+ }
198
+ if(!is_array($chiamata)) { $chiamata = array($chiamata); }
199
+ foreach($chiamata as $quote_available){
200
+ $carrier = Mage::getModel('sendabox_sendabox/carrier')->load($quote_available['idcarrier'],'carrier_id');
201
+ $id = $carrier ? $carrier->getId() : 3 ;
202
+ $allowedCarriers = explode(',', Mage::getStoreConfig('carriers/sendabox_sendabox/allowed_methods'));
203
+ if(!in_array($carrier->getCarrierId(), $allowedCarriers)){
204
+ continue;}
205
+ $existing_quote = Mage::getModel('sendabox_sendabox/quote')->getCollection()
206
+ ->addFieldToFilter('magento_quote_id', $this->getOrder()->getQuoteId())
207
+ ->addFieldToFilter('carrier_id', $id)
208
+ ->addFieldToFilter('commercial_name', $quote_available['commercialname'])->getFirstItem();
209
+ if($existing_quote->getTotalPrice() < $quote_available['price']){
210
+ $existing_quote->delete()->save();
211
+ $quote=Mage::getModel('sendabox_sendabox/quote')
212
+ ->setCarrierID($id)
213
+ ->setAccepted(1)
214
+ ->setTotalPrice($quote_available['price'])
215
+ ->setBasePrice($quote_available['price'])
216
+ ->setTax(0)
217
+ ->setInsuranceTotalPrice(0)
218
+ ->setCurrency('€')
219
+ ->setIdPrice($quote_available['idprice'])
220
+ ->setCommercialName($quote_available['commercialname'])
221
+ ->save();
222
+
223
+ if($salesQuoteId) $quote->setMagentoQuoteId($salesQuoteId)->save();
224
+ }
225
+ }
226
+ } else {
227
+ echo 'ERRORE CHIAMATA';
228
+ }
229
+ }
230
+ }
app/code/community/Sendabox/Sendabox/Model/Shipping/Carrier/Sendabox.php ADDED
@@ -0,0 +1,320 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Sendabox_Sendabox_Model_Shipping_Carrier_Sendabox extends Mage_Shipping_Model_Carrier_Abstract implements Mage_Shipping_Model_Carrier_Interface {
4
+
5
+ protected $_code = 'sendabox_sendabox';
6
+ protected $_title;
7
+ protected $request_new;
8
+ protected $request_old;
9
+ protected $_pricing_method;
10
+ protected $_from;
11
+
12
+ public function __construct()
13
+ {
14
+ parent::__construct();
15
+ $this->_pricing_method = Mage::getStoreConfig( 'sendabox_options/pricing/method');
16
+ $this->_from = Mage::getStoreConfig('sendabox_options/origin/city_id');
17
+ $this->_title = 'Sendabox';
18
+ }
19
+
20
+ public function collectRates(Mage_Shipping_Model_Rate_Request $request) {
21
+
22
+ $to_name = $request->getDestCity();
23
+ $region = $request->getDestRegionCode();
24
+
25
+ $result = Mage::getModel('shipping/rate_result');
26
+ /* @var $result Mage_Shipping_Model_Rate_Result */
27
+
28
+ //check origin/destination country
29
+ if (!$this->_canShip($request)) {
30
+ return;
31
+ }
32
+
33
+ $quote=Mage::getModel('sendabox_sendabox/quote');
34
+
35
+ $salesQuoteId = Mage::getSingleton('checkout/session')->getQuoteId();
36
+ if (!$salesQuoteId && Mage::app()->getStore()->isAdmin()) {
37
+ $salesQuoteId = Mage::getSingleton('adminhtml/session_quote')->getQuote()->getId();
38
+ }
39
+ if (!$salesQuoteId && $this->getIsProductPage()) {
40
+ $salesQuoteId = 100000000 + mt_rand(0, 100000);
41
+ }
42
+
43
+ $total_weight = 0;
44
+ foreach ($request->getAllItems() as $item) {
45
+ /* @var $item Mage_Sales_Model_Quote_Item */
46
+ if ($item->getProduct()->isVirtual() || $item->getParentItem()) { continue; }
47
+
48
+
49
+ $qty = $item->getQty() ? $item->getQty() : $item->getQtyOrdered();
50
+ $value = $item->getWeight() * $qty;
51
+
52
+ $total_weight += $value;
53
+ }
54
+ $total_weight = ceil($total_weight);
55
+ $lastRequest = Mage::getSingleton('checkout/session')->getSendaboxRequestString();
56
+ $to_id = $this->getCityId($to_name, $region);
57
+ if($to_id==0) return;
58
+ $new_request = $this->_from .'_' .$to_id .'_' .$total_weight .'_10,10,10_' .$salesQuoteId;
59
+ if ($lastRequest !== $new_request){
60
+ $quotes_to_clear = Mage::getModel('sendabox_sendabox/quote')->getCollection()
61
+ ->addFieldToFilter('magento_quote_id', $salesQuoteId);
62
+ foreach ($quotes_to_clear as $quote) {
63
+ /* @var $quote Sendabox_Sendabox_Model_Quote */
64
+ $quote->delete();
65
+ }
66
+ $this->getQuotes($this->_from,$to_id,$total_weight,'10,10,10',$salesQuoteId,'STANDARD');
67
+ $this->getQuotes($this->_from,$to_id,$total_weight,'10,10,10',$salesQuoteId,11);
68
+ $this->getQuotes($this->_from,$to_id,$total_weight,'10,10,10',$salesQuoteId,13);
69
+ }
70
+ Mage::getSingleton('checkout/session')->setSendaboxRequestString($this->_from .'_' .$to_id .'_' .$total_weight .'_10,10,10_' .$salesQuoteId);
71
+ //check if eligible for free shipping
72
+ if ($this->isFreeShipping($request)) {
73
+ $result->append($this->_getFreeRateMethod());
74
+ return $result;
75
+ }
76
+ if($this->_pricing_method == Sendabox_Sendabox_Model_System_Config_Source_Pricing::FLAT_RATE){
77
+ $result->append($this->_getFlatRateMethod());
78
+ return $result;
79
+ }
80
+
81
+ $quotes = Mage::getModel('sendabox_sendabox/quote')->getCollection()
82
+ ->addFieldToFilter('magento_quote_id', $salesQuoteId)
83
+ ->getItems();
84
+ if(!is_array($quotes)) { $quotes = array($quotes); }
85
+ foreach($quotes as $quote){
86
+ $method_title = 'sendabox_' . $quote->getId();
87
+ $result->append($this->_getRateFromQuote($quote,$method_title));
88
+ }
89
+ return $result;
90
+ }
91
+
92
+
93
+ /**
94
+ * Returns true if request is elegible for free shipping, false otherwise
95
+ *
96
+ * @param Mage_Shipping_Model_Rate_Request $request
97
+ * @return boolean
98
+ */
99
+ public function isFreeShipping($request)
100
+ {
101
+ //check pricing method first
102
+ if($this->_pricing_method == Sendabox_Sendabox_Model_System_Config_Source_Pricing::FREE) {
103
+ return true;
104
+ }
105
+
106
+ //check if all items have free shipping or free shipping over amount enabled and valid for this request
107
+ $allItemsFree = true; $total = 0;
108
+ foreach ($request->getAllItems() as $item) {
109
+ /* @var $item Mage_Sales_Model_Quote_Item */
110
+ if ($item->getProduct()->isVirtual() || $item->getParentItem()) { continue; }
111
+ if ($item->getFreeShipping()) { continue; }
112
+
113
+ $value = $item->getValue();
114
+ if (!$value) { $value = $item->getRowTotalInclTax(); }
115
+ if (!$value) { $value = $item->getRowTotal(); }
116
+ if (!$value) {
117
+ $qty = $item->getQty() ? $item->getQty() : $item->getQtyOrdered();
118
+ $value = $item->getPrice() * $qty;
119
+ }
120
+ $total += $value;
121
+ //not all items with free shipping if here
122
+ $allItemsFree = false;
123
+ }
124
+
125
+ if($allItemsFree ||
126
+ ($this->getConfigData('free_shipping_enable') && $total >= $this->getConfigData('free_shipping_subtotal'))) {
127
+ return true;
128
+ }
129
+
130
+ return false;
131
+ }
132
+
133
+ /**
134
+ * Creates the flat rate method, with the price set in the config. An
135
+ * optional parameter allows the price to be overridden.
136
+ *
137
+ * @return Mage_Shipping_Model_Rate_Result_Method
138
+ */
139
+ protected function _getFreeRateMethod()
140
+ {
141
+ $title = 'Free Shipping';
142
+ $method = Mage::getModel('shipping/rate_result_method')
143
+ ->setCarrier($this->_code)
144
+ ->setCarrierTitle($this->_title)
145
+ ->setMethodTitle($title)
146
+ ->setMethod('sendabox_' .Sendabox_Sendabox_Model_Carrier::FREE)
147
+ ->setPrice(0.00)
148
+ ->setCost(0.00);
149
+
150
+ return $method;
151
+ }
152
+
153
+ /**
154
+ * Creates the flat rate method, with the price set in the config. An
155
+ * optional parameter allows the price to be overridden.
156
+ *
157
+ * @return Mage_Shipping_Model_Rate_Result_Method
158
+ */
159
+ protected function _getFlatRateMethod()
160
+ {
161
+ $title = 'Flat Shipping';
162
+ $price = Mage::helper('sendabox_sendabox')->getConfigData('pricing/shipping_fee');
163
+ $method = Mage::getModel('shipping/rate_result_method')
164
+ ->setCarrier($this->_code)
165
+ ->setCarrierTitle($this->_title)
166
+ ->setMethodTitle($title)
167
+ ->setMethod('sendabox_' .Sendabox_Sendabox_Model_Carrier::FLAT_RATE)
168
+ ->setPrice($price)
169
+ ->setCost(0.00);
170
+
171
+ return $method;
172
+ }
173
+
174
+ protected function getQuotes($from=0, $to= 0, $weight, $dimensions='10,10,10', $salesQuoteId=null,$special='STANDARD'){
175
+
176
+ /*if(!$from || !$to || !$weight)
177
+ return false;*/
178
+
179
+ $url='http://www.sendabox.it/_magento/get/prices?from=' .$from .'&to=' .$to .'&weight=' .$weight .'&dimensions=' .$dimensions;
180
+ if($special)
181
+ $url .= '&special=' .$special;
182
+
183
+ $html = file_get_contents($url);
184
+
185
+ if ($html) {
186
+ $chiamata = json_decode($html, true);
187
+ if(!is_array($chiamata)) { $chiamata = array($chiamata); }
188
+ foreach($chiamata as $quote_available){
189
+ $carrier = Mage::getModel('sendabox_sendabox/carrier')->load($quote_available['idcarrier'],'carrier_id');
190
+ $id = $carrier ? $carrier->getId() : 3 ;
191
+ $allowedCarriers = explode(',', Mage::getStoreConfig('carriers/sendabox_sendabox/allowed_methods'));
192
+ if($allowedCarriers != '' && !in_array($carrier->getCarrierId(), $allowedCarriers))
193
+ continue;
194
+ $quote=Mage::getModel('sendabox_sendabox/quote')
195
+ ->setCarrierID($id)
196
+ ->setAccepted(1)
197
+ ->setTotalPrice($quote_available['price'])
198
+ ->setBasePrice($quote_available['price'])
199
+ ->setTax(0)
200
+ ->setInsuranceTotalPrice(0)
201
+ ->setCurrency('€')
202
+ ->setIdPrice($quote_available['idprice'])
203
+ ->setCommercialName($quote_available['commercialname'])
204
+ ->save();
205
+
206
+ if($salesQuoteId) $quote->setMagentoQuoteId($salesQuoteId)->save();
207
+ }
208
+ } else {
209
+ echo 'ERRORE CHIAMATA';
210
+ }
211
+ }
212
+
213
+ /**
214
+ * Creates a rate method based on a Sendabox quote.
215
+ *
216
+ * @param Mage_Shipping_Model_Rate_Result_Method the quote
217
+ *
218
+ * @return Mage_Shipping_Model_Rate_Result_Method
219
+ */
220
+ protected function _getRateFromQuote($quote, $method_id)
221
+ {
222
+ $price = $quote->getTotalPrice();
223
+ $title = $quote->getDescription();
224
+
225
+ $method = Mage::getModel('shipping/rate_result_method');
226
+ $method->setCarrier($this->_code);
227
+ $method->setCarrierTitle($this->_title);
228
+ $method->setMethodTitle($title);
229
+ $method->setMethod($method_id);
230
+ $method->setPrice($price);
231
+ $method->setCost(0);
232
+ Mage::log(
233
+ "carrier: {$method->getCarrier()}, CarrierTitle: {$method->getCarrierTitle()}, MethodTitle: {$method->getMethodTitle()}, Method: {$method->getMethod()}, Price: {$method->getPrice()}, Cost: {$method->getCost()}",
234
+ null,
235
+ 'createSendaboxShippingMethod.log', true
236
+ );
237
+ return $method;
238
+ }
239
+
240
+ protected function getCityId($city_name, $region_name="sa"){
241
+ $city = str_replace(" ", "%20", $city_name);
242
+ $url = 'http://www.sendabox.it/_magento/get/city?q=' .$city;
243
+ $html = file_get_contents($url);
244
+ Mage::log(
245
+ "{$html}",
246
+ null,
247
+ 'getCityId.log', true
248
+ );
249
+ if ($html) {
250
+ $chiamata = json_decode($html, true);
251
+ $safe_return = 14323;
252
+ if(!is_array($chiamata)) { $chiamata = array($chiamata); }
253
+ if(isset($chiamata['error']) && $chiamata['error']){
254
+ //echo $chiamata['msg'];
255
+ return $safe_return;
256
+ }
257
+ else {
258
+ if(count($chiamata)==0) return $safe_return;
259
+ $i=0;
260
+ foreach($chiamata as $suggest){
261
+ $name = strtolower(trim(explode('-',$suggest['value'])[0]));
262
+ $city_tmp = strtolower(trim($city_name));
263
+ Mage::log(
264
+ "suggerito: {$name}, inserito: {$city_tmp}",
265
+ null,
266
+ 'getCityId.log', true
267
+ );
268
+ if($name==$city_tmp){
269
+ $i++;
270
+ $region_tmp = strtolower(trim($region_name));
271
+ $abbreviation = strtolower($suggest['abbreviation']);
272
+ $province = strtolower($suggest['province']);
273
+ if($region_tmp ==$abbreviation || $region_tmp==$province){
274
+ $id= $suggest['id'];
275
+ return $id;
276
+ }
277
+ $safe_return = $i<2 ? $suggest['id'] : 14323;
278
+ }
279
+ }
280
+ return $safe_return;
281
+ }
282
+ } else {
283
+ //echo 'ERRORE CHIAMATA';
284
+ return 14323;
285
+ }
286
+ }
287
+
288
+ /**
289
+ * Checks if the to address is within allowed countries
290
+ *
291
+ * @return boolean
292
+ */
293
+ protected function _canShip(Mage_Shipping_Model_Rate_Request $request)
294
+ {
295
+ return array_key_exists($request->getDestCountryId(), Mage::helper('sendabox_sendabox')->getAllowedCountries());
296
+ }
297
+
298
+ /**
299
+ * Check if carrier has shipping tracking option available
300
+ *
301
+ * @return boolean
302
+ */
303
+ public function isTrackingAvailable()
304
+ {
305
+ return false;
306
+ }
307
+
308
+ /*public function getAllowedMethods()
309
+ {
310
+ return array(
311
+ 'standard' => 'Standard',
312
+ 'express' => 'Express',
313
+ );
314
+ }*/
315
+
316
+ public function getAllowedMethods()
317
+ {
318
+ return explode(',', Mage::getStoreConfig('carriers/sendabox_sendabox/allowed_methods'));
319
+ }
320
+ }
app/code/community/Sendabox/Sendabox/Model/Shipping/Carrier/Sendabox/Source/Method.php ADDED
@@ -0,0 +1,74 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Sendabox_Sendabox_Model_Shipping_Carrier_Sendabox_Source_Method
4
+ {
5
+
6
+ public function toOptionArray()
7
+ {
8
+ $options = array();
9
+
10
+ $carriers = Mage::getModel('sendabox_sendabox/carrier')->getCollection();
11
+ foreach ($carriers as $carrier) {
12
+ $options[] = array('value' => $carrier->getCarrierId(), 'label' => $carrier->getCompanyName());
13
+ }
14
+
15
+ return $options;
16
+ }
17
+
18
+
19
+ /**
20
+ * Gets all the options in the key => value type array.
21
+ *
22
+ * @return array
23
+ */
24
+ public function getOptions($please_select = false)
25
+ {
26
+ if ($please_select) {
27
+ $options = array(null => '--Please Select--');
28
+ }
29
+
30
+ $carriers = Mage::getModel('sendabox_sendabox/carrier')->getCollection();
31
+ foreach ($carriers as $carrier) {
32
+ if(!$carrier->getCarrierId())
33
+ continue;
34
+
35
+ $options[$carrier->getCarrierId()] = $carrier->getCompanyName();
36
+ }
37
+
38
+ return $options;
39
+ }
40
+
41
+ /**
42
+ * Gets all the options for html form.
43
+ *
44
+ * @return array ( 0 => array(
45
+ * 'label' = 'my label',
46
+ * 'value' = 'my value'
47
+ * )
48
+ * );
49
+ */
50
+ public function getOptionsForForm($enabledOnly = false)
51
+ {
52
+ $options = array();
53
+ $carriers = Mage::getModel('sendabox_sendabox/carrier')->getCollection();
54
+ foreach ($carriers as $carrier) {
55
+ if(!$carrier->getCarrierId())
56
+ continue;
57
+
58
+ //skip carriers which are not allowed in config
59
+ if($enabledOnly) {
60
+ $allowedCarriers = explode(',', Mage::getStoreConfig('carriers/sendabox_sendabox/allowed_methods'));
61
+ if(!in_array($carrier->getCarrierId(), $allowedCarriers)) {
62
+ continue;
63
+ }
64
+ }
65
+
66
+ $options[] = array(
67
+ 'label' => $carrier->getCompanyName(),
68
+ 'value' => $carrier->getCarrierId()
69
+ );
70
+ }
71
+
72
+ return $options;
73
+ }
74
+ }
app/code/community/Sendabox/Sendabox/Model/System/Config/Backend/Form/Field/Required/Text.php ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Sendabox_Sendabox_Model_System_Config_Backend_Form_Field_Required_Text extends Mage_Core_Model_Config_Data
4
+ {
5
+
6
+ protected function _beforeSave()
7
+ {
8
+ $value = $this->getValue();
9
+ $config = $this->getFieldConfig();
10
+
11
+ if (!Zend_Validate::is($value, 'NotEmpty')) {
12
+ Mage::throwException(Mage::helper('sendabox')->__('"' . $config->label . '" is a required field.', $value));
13
+ }
14
+ return $this;
15
+ }
16
+
17
+ }
app/code/community/Sendabox/Sendabox/Model/System/Config/Source.php ADDED
@@ -0,0 +1,82 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ abstract class Sendabox_Sendabox_Model_System_Config_Source
4
+ {
5
+
6
+ /**
7
+ * The array of options in the configuration item.
8
+ *
9
+ * This array's keys are the values used in the database etc. and the
10
+ * values of this array are used as labels on the frontend.
11
+ *
12
+ * @var array
13
+ */
14
+ protected $_options;
15
+
16
+ public function __construct()
17
+ {
18
+ $this->_setupOptions();
19
+ }
20
+
21
+ /**
22
+ * Sets up the $_options array with the correct values.
23
+ *
24
+ * This function is called in the constructor.
25
+ *
26
+ * @return Temando_Temando_Model_System_Config_Source_Abstract
27
+ */
28
+ protected abstract function _setupOptions();
29
+
30
+ /**
31
+ * Gets all the options in the key => value type array.
32
+ *
33
+ * @return array
34
+ */
35
+ public function getOptions($please_select = false)
36
+ {
37
+ $options = $this->_options;
38
+ if ($please_select) {
39
+ $options = array(null => '--Please Select--') + $options;
40
+ }
41
+ return $options;
42
+ }
43
+
44
+ /**
45
+ * Converts the options into a format suitable for use in the admin area.
46
+ *
47
+ * @return array
48
+ */
49
+ public function toOptionArray()
50
+ {
51
+ return $this->_toOptionArray($this->_options);
52
+ }
53
+
54
+ protected function _toOptionArray($input)
55
+ {
56
+ $array = array();
57
+
58
+ foreach ($input as $key => $value) {
59
+ $array[] = array(
60
+ 'value' => $key,
61
+ 'label' => $value,
62
+ );
63
+ }
64
+
65
+ return $array;
66
+ }
67
+
68
+ /**
69
+ * Looks up an option by key and gets the label.
70
+ *
71
+ * @param mixed $value
72
+ * @return mixed
73
+ */
74
+ public function getOptionLabel($value)
75
+ {
76
+ if (array_key_exists($value, $this->_options)) {
77
+ return $this->_options[$value];
78
+ }
79
+ return null;
80
+ }
81
+
82
+ }
app/code/community/Sendabox/Sendabox/Model/System/Config/Source/Errorprocess.php ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Sendabox_Sendabox_Model_System_Config_Source_Errorprocess extends Sendabox_Sendabox_Model_System_Config_Source
4
+ {
5
+
6
+ const VIEW = 'view';
7
+ const FLAT = 'flat';
8
+
9
+ protected function _setupOptions()
10
+ {
11
+ $this->_options = array(
12
+ self::FLAT => 'Show flat rate',
13
+ self::VIEW => 'Show error message',
14
+ );
15
+ }
16
+
17
+ }
app/code/community/Sendabox/Sendabox/Model/System/Config/Source/Insurance.php ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Sendabox_Sendabox_Model_System_Config_Source_Insurance extends Sendabox_Sendabox_Model_System_Config_Source
4
+ {
5
+
6
+ const DISABLED = 'disabled';
7
+ const OPTIONAL = 'optional';
8
+ const MANDATORY = 'mandatory';
9
+
10
+ protected function _setupOptions()
11
+ {
12
+ $this->_options = array(
13
+ self::DISABLED => 'Disabled',
14
+ self::OPTIONAL => 'Optional',
15
+ self::MANDATORY => 'Mandatory',
16
+ );
17
+ }
18
+
19
+ }
app/code/community/Sendabox/Sendabox/Model/System/Config/Source/Pricing.php ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Sendabox_Sendabox_Model_System_Config_Source_Pricing extends Sendabox_Sendabox_Model_System_Config_Source
4
+ {
5
+
6
+ const FREE = 'free';
7
+ const FLAT_RATE = 'flat';
8
+ const DYNAMIC = 'dynamic';
9
+ //const DYNAMIC_CHEAPEST = 'dynamiccheap';
10
+
11
+ protected function _setupOptions()
12
+ {
13
+ $this->_options = array(
14
+ self::FREE => 'Free Shipping',
15
+ self::FLAT_RATE => 'Fixed Price / Flat Rate',
16
+ self::DYNAMIC => 'Dynamic Pricing (All)',
17
+ //self::DYNAMIC_CHEAPEST => 'Dynamic Pricing (Cheapest only)',
18
+ );
19
+ }
20
+
21
+ }
app/code/community/Sendabox/Sendabox/Model/System/Config/Source/Shipment/Status.php ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Sendabox_Sendabox_Model_System_Config_Source_Shipment_Status extends Sendabox_Sendabox_Model_System_Config_Source
4
+ {
5
+
6
+ const PENDING = '0';
7
+ const BOOKED = '1';
8
+
9
+ protected function _setupOptions()
10
+ {
11
+ $this->_options = array(
12
+ self::PENDING => Mage::helper('sendabox_sendabox')->__('Pending'),
13
+ self::BOOKED => Mage::helper('sendabox_sendabox')->__('Booked'),
14
+ );
15
+ }
16
+
17
+ }
app/code/community/Sendabox/Sendabox/Model/System/Config/Source/Unit.php ADDED
@@ -0,0 +1,56 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ abstract class Sendabox_Sendabox_Model_System_Config_Source_Unit extends Sendabox_Sendabox_Model_System_Config_Source
4
+ {
5
+
6
+ /**
7
+ * Same as the parent::_options array, except with brief labels as values.
8
+ *
9
+ * As the $_options array will contain the name of the unit (e.g. "Metres",
10
+ * "Inches"), this will contain a shorter description e.g. the units when
11
+ * used after a measurement ("m.", "in.", etc).
12
+ *
13
+ * @var array
14
+ */
15
+ protected $_brief_options;
16
+
17
+ public function __construct()
18
+ {
19
+ parent::__construct();
20
+ $this->_setupBriefOptions();
21
+ }
22
+
23
+ /**
24
+ * Sets up the $_brief_options array with the correct values.
25
+ *
26
+ * This function is called in the constructor.
27
+ *
28
+ * @return Temando_Temando_Model_System_Config_Source_Abstract
29
+ */
30
+ protected abstract function _setupBriefOptions();
31
+
32
+ /**
33
+ * Looks up an option by key and gets the label.
34
+ *
35
+ * @param mixed $value
36
+ * @return mixed
37
+ */
38
+ public function getBriefOptionLabel($value)
39
+ {
40
+ if (array_key_exists($value, $this->_brief_options)) {
41
+ return $this->_brief_options[$value];
42
+ }
43
+ return null;
44
+ }
45
+
46
+ public function toBriefOptionArray()
47
+ {
48
+ return $this->_toOptionArray($this->_brief_options);
49
+ }
50
+
51
+ public function getOptionValue($value)
52
+ {
53
+ return array_search($value, array_flip($this->_brief_options));
54
+ }
55
+
56
+ }
app/code/community/Sendabox/Sendabox/Model/System/Config/Source/Unit/Measure.php ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Sendabox_Sendabox_Model_System_Config_Source_Unit_Measure extends Sendabox_Sendabox_Model_System_Config_Source_Unit
4
+ {
5
+
6
+ const CENTIMETRES = 'Centimetres';
7
+ const INCHES = 'Inches';
8
+ const FEET = 'Feet';
9
+
10
+ protected function _setupOptions()
11
+ {
12
+ $this->_options = array(
13
+ self::CENTIMETRES => 'Centimetres',
14
+ self::INCHES => 'Inches',
15
+ self::FEET => 'Feet',
16
+ );
17
+ }
18
+
19
+ protected function _setupBriefOptions()
20
+ {
21
+ $this->_brief_options = array(
22
+ self::CENTIMETRES => 'cm',
23
+ self::INCHES => 'in.',
24
+ self::FEET => 'ft.',
25
+ );
26
+ }
27
+
28
+ }
app/code/community/Sendabox/Sendabox/Model/System/Config/Source/Unit/Weight.php ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Sendabox_Sendabox_Model_System_Config_Source_Unit_Weight extends Sendabox_Sendabox_Model_System_Config_Source_Unit
4
+ {
5
+
6
+ const KILOGRAMS = 'Kilograms';
7
+ const OUNCES = 'Ounces';
8
+ const POUNDS = 'Pounds';
9
+
10
+ protected function _setupOptions()
11
+ {
12
+ $this->_options = array(
13
+ self::KILOGRAMS => 'Kilograms',
14
+ self::OUNCES => 'Ounces',
15
+ self::POUNDS => 'Pounds',
16
+ );
17
+ }
18
+
19
+ protected function _setupBriefOptions()
20
+ {
21
+ $this->_brief_options = array(
22
+ self::KILOGRAMS => 'kg',
23
+ self::OUNCES => 'oz.',
24
+ self::POUNDS => 'lb.',
25
+ );
26
+ }
27
+
28
+ }
app/code/community/Sendabox/Sendabox/controllers/Adminhtml/ShipmentController.php ADDED
@@ -0,0 +1,260 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Sendabox_Sendabox_Adminhtml_ShipmentController extends Mage_Adminhtml_Controller_Action {
4
+
5
+ public function indexAction() {
6
+ $this->loadLayout()
7
+ ->_setActiveMenu('sendabox/shipment')
8
+ ->_addBreadcrumb(Mage::helper('adminhtml')->__('Shipment Manager'), Mage::helper('adminhtml')->__('Shipment Manager'))
9
+ ->renderLayout();
10
+ }
11
+
12
+ public function editAction() {
13
+ $id = $this->getRequest()->getParam('id');
14
+ $shipment = Mage::getModel('sendabox_sendabox/shipment')->load($id);
15
+ /* @var $shipment Sendabox_Sendabox_Model_Shipment */
16
+
17
+ if ($shipment->getId()) {
18
+ $notices = array();
19
+
20
+ if (!count($shipment->getBoxes())) {
21
+ $notices[] = 'Quotes cannot be refreshed until at least one box is added to the shipment.';
22
+ }
23
+ if (!count($shipment->getQuotes())){
24
+ $notices[] = 'No quotes available for the boxes of the shipment';
25
+ }
26
+ if($this->checkCredits() == 0){
27
+ $this->_getSession()->addError('No credits remaining or error in the settings configuration of the extension');
28
+ //$notices[] = 'No credits remaining or error in the settings configuration of the extension';
29
+ }
30
+ if($this->checkCredits() != 0 && $this->checkCredits()<= 10){
31
+ $notices[] = 'Check your credits, only {$this->checkCredits()} remaining';
32
+ }
33
+ foreach ($notices as $notice) {
34
+ $this->_getSession()->addNotice($this->__($notice));
35
+ }
36
+
37
+ $data = Mage::getSingleton('adminhtml/session')->getFormData(true);
38
+ if (!empty($data)) {
39
+ $shipment->addData($data);
40
+ }
41
+
42
+ Mage::register('sendabox_shipment_data', $shipment);
43
+
44
+ $this->loadLayout()
45
+ ->_setActiveMenu('sendabox/shipment');
46
+
47
+ /*$this->getLayout()->getBlock('head')->setCanLoadExtJs(true);*/
48
+
49
+ $this->renderLayout();
50
+ } else {
51
+ Mage::getSingleton('adminhtml/session')->addError($this->__('Shipment does not exist.'));
52
+ $this->_redirect('*/*/');
53
+ }
54
+ }
55
+
56
+ public function saveAction() {
57
+ if ($data = $this->getRequest()->getPost()) {
58
+ $shipment = Mage::getModel('sendabox_sendabox/shipment');
59
+
60
+ try {
61
+ $shipment->setId($this->getRequest()->getParam('id'))
62
+ ->addData($data)->save();
63
+
64
+ if ($data['boxes_deleted']) {
65
+ $box_ids = explode(',', $data['boxes_deleted']);
66
+ foreach ($box_ids as $box_id) {
67
+ $box = Mage::getModel('sendabox_sendabox/box');
68
+ /* @var $box Sendabox_Sendabox_Model_Box */
69
+ $box->load($box_id);
70
+ if ($box->getId()) {
71
+ $box->delete();
72
+ }
73
+ }
74
+ }
75
+
76
+ if (isset($data['box']) && is_array($data['box'])) {
77
+ foreach ($data['box'] as $box_data) {
78
+
79
+ $box = Mage::getModel('sendabox_sendabox/box');
80
+ /* @var $box Sendabox_Sendabox_Model_Box */
81
+ if (isset($box_data['id'])) {
82
+ $box->load($box_data['id']);
83
+ }
84
+
85
+ $box->setShipmentId($shipment->getId())
86
+ ->addData($box_data)
87
+ ->save();
88
+ }
89
+ }
90
+
91
+
92
+ $shipment = Mage::getModel('sendabox_sendabox/shipment')->load($shipment->getId());
93
+ $shipment->clearQuotes()->save();
94
+ if ($shipment->getBoxes()) {
95
+ $shipment->getNewQuotes();
96
+ }
97
+
98
+ $this->_getSession()->addSuccess($this->__('The shipment data has been saved.'));
99
+
100
+
101
+ $this->_redirect('*/*/edit', array('id' => $shipment->getId()));
102
+ } catch (Exception $ex) {
103
+ $this->_getSession()->addError($ex->getMessage())->setFormData($data);
104
+ $this->_redirect('*/*/edit', array('id' => $this->getRequest()->getParam('id')));
105
+ }
106
+ return;
107
+ }
108
+
109
+ // nothing to save
110
+ $this->_redirect('*/*/');
111
+ }
112
+
113
+ public function bookAction() {
114
+ $shipment_id = $this->getRequest()->getParam('shipment');
115
+ $shipment = Mage::getModel('sendabox_sendabox/shipment')
116
+ ->load($shipment_id);
117
+ /* @var $shipment Sendabox_Sendabox_Model_Shipment */
118
+
119
+ $quote_id = $this->getRequest()->getParam('quote');
120
+ $quote = Mage::getModel('sendabox_sendabox/quote')
121
+ ->load($quote_id);
122
+ /* @var $quote Sendabox_Sendabox_Model_Quote */
123
+
124
+ $error = null;
125
+
126
+ if (!$shipment->getId()) {
127
+ $error = 'Shipment does not exist.';
128
+ } else {
129
+ if (!$quote->getId()) {
130
+ $error = 'Selected quote does not exist.';
131
+ } else {
132
+ $username = Mage::helper('sendabox_sendabox')->getConfigData('general/username');
133
+ $password = Mage::helper('sendabox_sendabox')->getConfigData('general/password');
134
+ if (!$error && $username !='test' && $password !='test') {
135
+ // try to make booking
136
+ try {
137
+ $booking_result = $this->_makeBooking($shipment, $quote);
138
+ } catch (Exception $ex) {
139
+ $error = $ex->getMessage();
140
+ }
141
+ }
142
+ }
143
+ }
144
+
145
+ if (!$error) {
146
+
147
+ $shipment
148
+ ->setAdminSelectedQuoteId($quote_id)
149
+ ->setStatus(Sendabox_Sendabox_Model_System_Config_Source_Shipment_Status::BOOKED)
150
+ ->setCustomerCost($quote->getTotalPrice())
151
+ ->save();
152
+
153
+ $magento_shipment = Mage::getModel('sales/convert_order')
154
+ ->toShipment($shipment->getOrder());
155
+ /* @var $magento_shipment Mage_Sales_Model_Order_Shipment */
156
+
157
+ $totalQty = 0;
158
+ foreach ($shipment->getOrder()->getAllItems() as $item) {
159
+ if ($item->getQtyToShip() && !$item->getIsVirtual()) {
160
+ $magento_shipment_item = Mage::getModel('sales/convert_order')
161
+ ->itemToShipmentItem($item);
162
+
163
+ $qty = $item->getQtyToShip();
164
+
165
+ $magento_shipment_item->setQty($qty);
166
+ $magento_shipment->addItem($magento_shipment_item);
167
+
168
+ $totalQty += $qty;
169
+ }
170
+ }
171
+
172
+ $magento_shipment->setTotalQty($totalQty);
173
+
174
+ try {
175
+ $magento_shipment->getOrder()->setIsInProcess(true)->setCustomerNoteNotify(true);
176
+ Mage::getModel('core/resource_transaction')
177
+ ->addObject($shipment)
178
+ ->addObject($magento_shipment)
179
+ ->addObject($magento_shipment->getOrder())
180
+ ->save();
181
+ $magento_shipment->sendEmail();
182
+ } catch (Mage_Core_Exception $e) {
183
+ $error = $e->getMessage();
184
+ }
185
+
186
+ $this->_getSession()->addSuccess($this->__('Shipment booked.'));
187
+ }
188
+
189
+ if ($error) {
190
+ $this->_getSession()
191
+ ->addError($this->__($error))
192
+ /* ->setFormData($data) */;
193
+ }
194
+ $this->_redirect('*/*/edit', array('id' => $shipment_id));
195
+ }
196
+
197
+ protected function _makeBooking($shipment, $quote){
198
+ $username = Mage::helper('sendabox_sendabox')->getConfigData('general/username');
199
+ $password = Mage::helper('sendabox_sendabox')->getConfigData('general/password');
200
+ $nameFrom = Mage::getStoreConfig('sendabox_options/origin/contact_name');
201
+ $surnameFrom = Mage::getStoreConfig('sendabox_options/origin/contact_surname');
202
+ $careFrom = Mage::getStoreConfig('sendabox_options/origin/c_o');
203
+ $addressFrom = Mage::getStoreConfig('sendabox_options/origin/street');
204
+ $streetnumberFrom = Mage::getStoreConfig('sendabox_options/origin/number');
205
+ $cityFrom = Mage::getStoreConfig('sendabox_options/origin/city_id');
206
+ $zipFrom = Mage::getStoreConfig('sendabox_options/origin/postcode');
207
+ $notesFrom = Mage::getStoreConfig('sendabox_options/origin/notes');
208
+ $contactphoneFrom = Mage::getStoreConfig('sendabox_options/origin/phone');
209
+ $emailconfirmFrom = Mage::getStoreConfig('sendabox_options/origin/email');
210
+ foreach($shipment->getBoxes() as $box){
211
+ $weight = ceil($box->getWeight());
212
+ $dimensions = '' .ceil($box->getWidth()) .',' .ceil($box->getHeight()) .',' .ceil($box->getLength());
213
+ $url = 'http://www.sendabox.it/_magento/set/order?api_user=' .$username .'&api_secret=' .$password .'&weight=' .$weight .'&dimensions=' .$dimensions .'&nameFrom=' .$nameFrom .'&surnameFrom=' .$surnameFrom;
214
+ if($careFrom) $url .= '&careFrom=' .$careFrom;
215
+ $url .= '&addressFrom=' .$addressFrom .'&streetnumberFrom=' .$streetnumberFrom .'&cityFrom=' .$cityFrom .'&zipFrom=' .$zipFrom;
216
+ if($notesFrom) $url .= '&notesFrom=' .$notesFrom;
217
+ $url .= '&contactphoneFrom=' .$contactphoneFrom .'&emailconfirmFrom=' .$emailconfirmFrom .'&nameTo=' .$shipment->getDestinationName() .'&surnameTo=' .$shipment->getDestinationSurname();
218
+ if($shipment->getDestinationAt()) $url .= '&careTo=' .$shipment->getDestinationAt();
219
+ $url .= '&addressTo=' .$shipment->getDestinationStreet() .'&streetnumberTo=' .$shipment->getDestinationNumber() .'&cityTo=' .$shipment->getDestinationId() .'&zipTo=' .$shipment->getDestinationPostcode();
220
+ if($shipment->getDestinationNote()) $url .= '&notesTo=' .$shipment->getDestinationNote();
221
+ $url .= '&idprice=' .$quote->getIdPrice();
222
+ $url = str_replace(" ", "%20", $url);
223
+ $html = file_get_contents($url);
224
+ if ($html) {
225
+ $chiamata = json_decode($html, true);
226
+ if(!is_array($chiamata)) { $chiamata = array($chiamata); }
227
+ if(isset($chiamata['error']) && $chiamata['error']){
228
+ //echo $chiamata['msg'];
229
+ throw new Exception($chiamata['msg']);
230
+ }
231
+ else {
232
+ foreach($chiamata as $shipped_box){
233
+ $shipment_number = $shipped_box['id'];
234
+ }
235
+ }
236
+ } else {
237
+ //echo 'ERRORE CHIAMATA';
238
+ throw new Exception('Connection with the server failed');
239
+ }
240
+ }
241
+ }
242
+
243
+ protected function checkCredits(){
244
+ $username = Mage::helper('sendabox_sendabox')->getConfigData('general/username');
245
+ $password = Mage::helper('sendabox_sendabox')->getConfigData('general/password');
246
+ $url='http://www.sendabox.it/_magento/get/credits?api_user=' .$username .'&api_secret=' .$password;
247
+ $html = file_get_contents($url);
248
+ if ($html) {
249
+ $chiamata = json_decode($html, true);
250
+ if(isset($chiamata['error']) && $chiamata['error']){
251
+ return 0;
252
+ } else {
253
+ return $chiamata['credit'];
254
+ }
255
+ } else {
256
+ //exit('not html');
257
+ return 0;
258
+ }
259
+ }
260
+ }
app/code/community/Sendabox/Sendabox/etc/adminhtml.xml ADDED
@@ -0,0 +1,73 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <config>
2
+ <menu>
3
+ <sendabox translate="title" module="sendabox_sendabox">
4
+ <title>Sendabox</title>
5
+ <sort_order>75</sort_order>
6
+ <children>
7
+ <shipment translate="title" module="sendabox_sendabox">
8
+ <title>Manage Shipments</title>
9
+ <sort_order>10</sort_order>
10
+ <action>sendabox/adminhtml_shipment</action>
11
+ </shipment>
12
+ <configuration translate="title" module="sendabox_sendabox">
13
+ <title>Configuration Settings</title>
14
+ <sort_order>30</sort_order>
15
+ <children>
16
+ <sendabox_settings translate="title" module="sendabox_sendabox">
17
+ <title>Sendabox Settings</title>
18
+ <sort_order>10</sort_order>
19
+ <action>adminhtml/system_config/edit/section/sendabox_options</action>
20
+ </sendabox_settings>
21
+ <shipping_methods>
22
+ <title>Shipping Methods</title>
23
+ <sort_order>20</sort_order>
24
+ <action>adminhtml/system_config/edit/section/carriers</action>
25
+ </shipping_methods>
26
+ </children>
27
+ </configuration>
28
+ </children>
29
+ </sendabox>
30
+ </menu>
31
+ <acl>
32
+ <resources>
33
+ <all>
34
+ <title>Allow Everything</title>
35
+ </all>
36
+ <admin>
37
+ <children>
38
+ <sendabox translate="title" module="sendabox_sendabox">
39
+ <title>Sendabox</title>
40
+ <sort_order>10</sort_order>
41
+ <children>
42
+ <shipment>
43
+ <title>Manage Shipments</title>
44
+ </shipment>
45
+ <configuration>
46
+ <title>Configuration Settings</title>
47
+ <children>
48
+ <sendabox_settings>
49
+ <title>Sendabox Settings</title>
50
+ </sendabox_settings>
51
+ <shipping_methods>
52
+ <title>Shipping Methods</title>
53
+ </shipping_methods>
54
+ </children>
55
+ </configuration>
56
+ </children>
57
+ </sendabox>
58
+ <system>
59
+ <children>
60
+ <config>
61
+ <children>
62
+ <sendabox_settings>
63
+ <title>Sendabox Settings</title>
64
+ </sendabox_settings>
65
+ </children>
66
+ </config>
67
+ </children>
68
+ </system>
69
+ </children>
70
+ </admin>
71
+ </resources>
72
+ </acl>
73
+ </config>
app/code/community/Sendabox/Sendabox/etc/config.xml ADDED
@@ -0,0 +1,168 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <config>
2
+ <modules>
3
+ <Sendabox_Sendabox>
4
+ <version>1.0.0</version>
5
+ </Sendabox_Sendabox>
6
+ </modules>
7
+ <global>
8
+ <models>
9
+ <sendabox_sendabox>
10
+ <class>Sendabox_Sendabox_Model</class>
11
+ <resourceModel>sendabox_resource</resourceModel>
12
+ </sendabox_sendabox>
13
+ <sendabox_resource>
14
+ <class>Sendabox_Sendabox_Model_Resource</class>
15
+ <entities>
16
+ <box><table>sendabox_box</table></box>
17
+ <quote><table>sendabox_quote</table></quote>
18
+ <shipment><table>sendabox_shipment</table></shipment>
19
+ <carrier><table>sendabox_carrier</table></carrier>
20
+ </entities>
21
+ </sendabox_resource>
22
+ </models>
23
+ <helpers>
24
+ <sendabox_sendabox>
25
+ <class>Sendabox_Sendabox_Helper</class>
26
+ </sendabox_sendabox>
27
+ </helpers>
28
+ <blocks>
29
+ <sendabox_sendabox>
30
+ <class>Sendabox_Sendabox_Block</class>
31
+ </sendabox_sendabox>
32
+ </blocks>
33
+ <resources>
34
+ <sendabox_sendabox_setup>
35
+ <setup>
36
+ <module>Sendabox_Sendabox</module>
37
+ <class>Mage_Eav_Model_Entity_Setup</class>
38
+ </setup>
39
+ <connection>
40
+ <use>core_setup</use>
41
+ </connection>
42
+ </sendabox_sendabox_setup>
43
+ <sendabox_sendabox_write>
44
+ <connection>
45
+ <use>core_write</use>
46
+ </connection>
47
+ </sendabox_sendabox_write>
48
+ <sendabox_sendabox_read>
49
+ <connection>
50
+ <use>core_read</use>
51
+ </connection>
52
+ </sendabox_sendabox_read>
53
+ </resources>
54
+ <sales>
55
+ <shipping>
56
+ <carriers>
57
+ <sendabox_sendabox>
58
+ <class>Sendabox_Sendabox_Model_Shipping_Carrier_Sendabox</class>
59
+ </sendabox_sendabox>
60
+ </carriers>
61
+ </shipping>
62
+ </sales>
63
+ <events>
64
+ <sales_order_place_after>
65
+ <observers>
66
+ <sendabox_sendabox_sales_order_place_after_handler>
67
+ <type>model</type>
68
+ <class>Sendabox_Sendabox_Model_Observer</class>
69
+ <method>createSendaboxShipment</method>
70
+ </sendabox_sendabox_sales_order_place_after_handler>
71
+ </observers>
72
+ </sales_order_place_after>
73
+ </events>
74
+ </global>
75
+ <admin>
76
+ <routers>
77
+ <sendabox>
78
+ <use>admin</use>
79
+ <args>
80
+ <module>Sendabox_Sendabox</module>
81
+ <frontName>sendabox</frontName>
82
+ </args>
83
+ </sendabox>
84
+ </routers>
85
+ </admin>
86
+ <adminhtml>
87
+ <events>
88
+ <controller_action_layout_generate_blocks_after>
89
+ <observers>
90
+ <sendabox_sendabox_addjs>
91
+ <type>singleton</type>
92
+ <class>sendabox_sendabox/observer</class>
93
+ <method>addJavascriptBlock</method>
94
+ </sendabox_sendabox_addjs>
95
+ </observers>
96
+ </controller_action_layout_generate_blocks_after>
97
+ </events>
98
+ <acl>
99
+ <resources>
100
+ <admin>
101
+ <children>
102
+ <system>
103
+ <children>
104
+ <config>
105
+ <children>
106
+ <sendabox_options>
107
+ <title>Sendabox Section</title>
108
+ </sendabox_options>
109
+ </children>
110
+ </config>
111
+ </children>
112
+ </system>
113
+ </children>
114
+ </admin>
115
+ </resources>
116
+ </acl>
117
+ <layout>
118
+ <updates>
119
+ <sendabox>
120
+ <file>sendabox.xml</file>
121
+ </sendabox>
122
+ </updates>
123
+ </layout>
124
+ </adminhtml>
125
+ <!-- Default configuration -->
126
+ <default>
127
+ <carriers>
128
+ <sendabox_sendabox>
129
+ <active>1</active>
130
+ <!--
131
+ This configuration should not be made visible
132
+ to the administrator, because it specifies
133
+ the model to be used for this carrier.
134
+ -->
135
+ <model>sendabox_sendabox/shipping_carrier_sendabox</model>
136
+ <!--
137
+ The title as referenced in the carrier class
138
+ -->
139
+ <title>Sendabox - Confronta e spedisci a prezzi imbattibili</title>
140
+ <!--
141
+ The sort order specifies the position that
142
+ this carrier appears relative to the other
143
+ carriers available in checkout.
144
+ -->
145
+ <sort_order>10</sort_order>
146
+ <!--
147
+ Out of the box, Magento offers shipping
148
+ carriers the ability to restrict themselves
149
+ to specific countries. For this configuration
150
+ option, 0 means allow all countries available,
151
+ and 1 means allow all countries specified
152
+ in the country list that we will add later
153
+ in system.xml
154
+ -->
155
+ <sallowspecific>0</sallowspecific>
156
+ <!--
157
+ Inserimenti miei
158
+ -->
159
+ <!--<specificerrmsg>This shipping method is currently unavailable. If you would like to ship using this shipping method, please contact us.</specificerrmsg>-->
160
+ </sendabox_sendabox>
161
+ </carriers>
162
+ <sendabox_options>
163
+ <general>
164
+ <payment_type>Credits</payment_type>
165
+ </general>
166
+ </sendabox_options>
167
+ </default>
168
+ </config>
app/code/community/Sendabox/Sendabox/etc/system.xml ADDED
@@ -0,0 +1,476 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <config>
3
+ <sections>
4
+ <carriers translate="label" module="shipping">
5
+ <groups>
6
+ <sendabox_sendabox translate="label">
7
+ <label>Sendabox</label>
8
+ <frontend_type>text</frontend_type>
9
+ <sort_order>2</sort_order>
10
+ <show_in_default>1</show_in_default>
11
+ <show_in_website>1</show_in_website>
12
+ <show_in_store>1</show_in_store>
13
+ <fields>
14
+ <!--
15
+ The following fields are available
16
+ to modify in the admin panel.
17
+ The values are saved in the
18
+ database.
19
+
20
+ This shipping carrier abstract checks
21
+ this value to determine whether
22
+ the carrier should be shown.
23
+ -->
24
+ <active translate="label">
25
+ <label>Enabled</label>
26
+ <frontend_type>select</frontend_type>
27
+ <source_model>adminhtml/system_config_source_yesno</source_model>
28
+ <sort_order>1</sort_order>
29
+ <show_in_default>1</show_in_default>
30
+ <show_in_website>1</show_in_website>
31
+ <show_in_store>0</show_in_store>
32
+ </active>
33
+ <!--
34
+ This value can be used to specify a
35
+ custom title for our method.
36
+ -->
37
+ <!--<title translate="label">
38
+ <label>Title</label>
39
+ <frontend_type>text</frontend_type>
40
+ <sort_order>2</sort_order>
41
+ <show_in_default>1</show_in_default>
42
+ <show_in_website>1</show_in_website>
43
+ <show_in_store>1</show_in_store>
44
+ </title>-->
45
+ <!--
46
+ The sort order is used in Magento
47
+ to determine what order the carrier
48
+ will appear in relative to the
49
+ other carriers available.
50
+ -->
51
+ <!--<sort_order translate="label">
52
+ <label>Sort Order</label>
53
+ <frontend_type>text</frontend_type>
54
+ <sort_order>100</sort_order>
55
+ <show_in_default>1</show_in_default>
56
+ <show_in_website>1</show_in_website>
57
+ <show_in_store>0</show_in_store>
58
+ </sort_order>-->
59
+ <!--
60
+ This value is used to specify whether
61
+ the carrier is available only for
62
+ specific countries or all countries
63
+ available in the current Magento
64
+ installation.
65
+ -->
66
+ <sallowspecific translate="label">
67
+ <label>Ship to Applicable Countries</label>
68
+ <frontend_type>select</frontend_type>
69
+ <sort_order>90</sort_order>
70
+ <frontend_class>shipping-applicable-country</frontend_class>
71
+ <source_model>adminhtml/system_config_source_shipping_allspecificcountries</source_model>
72
+ <show_in_default>1</show_in_default>
73
+ <show_in_website>1</show_in_website>
74
+ <show_in_store>0</show_in_store>
75
+ </sallowspecific>
76
+ <!--
77
+ If 'specific countries' is chosen
78
+ in the previous option, then this field
79
+ allows the administrator to specify
80
+ which specific countries this carrier
81
+ should be available for.
82
+ -->
83
+ <specificcountry translate="label">
84
+ <label>Ship to Specific Countries</label>
85
+ <frontend_type>multiselect</frontend_type>
86
+ <sort_order>91</sort_order>
87
+ <source_model>adminhtml/system_config_source_country</source_model>
88
+ <show_in_default>1</show_in_default>
89
+ <show_in_website>1</show_in_website>
90
+ <show_in_store>0</show_in_store>
91
+ <can_be_empty>1</can_be_empty>
92
+ </specificcountry>
93
+ <free_shipping_enable translate="label">
94
+ <label>Free Shipping with Minimum Order Amount</label>
95
+ <frontend_type>select</frontend_type>
96
+ <source_model>adminhtml/system_config_source_enabledisable</source_model>
97
+ <sort_order>50</sort_order>
98
+ <show_in_default>1</show_in_default>
99
+ <show_in_website>1</show_in_website>
100
+ <show_in_store>1</show_in_store>
101
+ </free_shipping_enable>
102
+ <free_shipping_subtotal translate="label">
103
+ <label>Minimum Order Amount for Free Shipping</label>
104
+ <frontend_type>text</frontend_type>
105
+ <sort_order>60</sort_order>
106
+ <show_in_default>1</show_in_default>
107
+ <show_in_website>1</show_in_website>
108
+ <show_in_store>1</show_in_store>
109
+ </free_shipping_subtotal>
110
+ <allowed_methods translate="label">
111
+ <label>Allowed Carriers</label>
112
+ <frontend_type>multiselect</frontend_type>
113
+ <!--<config_path>carriers/sendabox/allowed_methods</config_path>-->
114
+ <sort_order>70</sort_order>
115
+ <source_model>sendabox_sendabox/shipping_carrier_sendabox_source_method</source_model>
116
+ <show_in_default>1</show_in_default>
117
+ <show_in_website>1</show_in_website>
118
+ <show_in_store>1</show_in_store>
119
+ <comment><![CDATA[Use CTRL + click to select multiple carriers.]]></comment>
120
+ </allowed_methods>
121
+ </fields>
122
+ </sendabox_sendabox>
123
+ </groups>
124
+ </carriers>
125
+ <sendabox_options translate="label" module="sendabox_sendabox">
126
+ <label>Sendabox Settings</label>
127
+ <tab>sales</tab>
128
+ <frontend_type>text</frontend_type>
129
+ <sort_order>321</sort_order>
130
+ <show_in_default>1</show_in_default>
131
+ <show_in_website>1</show_in_website>
132
+ <show_in_store>1</show_in_store>
133
+ <groups>
134
+ <general translate="label">
135
+ <label>General</label>
136
+ <frontend_model>sendabox_sendabox/adminhtml_system_config_form_fieldset_general</frontend_model>
137
+ <sort_order>10</sort_order>
138
+ <show_in_default>1</show_in_default>
139
+ <show_in_website>1</show_in_website>
140
+ <show_in_store>1</show_in_store>
141
+ <comment>
142
+ <![CDATA[
143
+ <div style="padding:10px;background-color:#fff;border:1px solid #ddd;margin-bottom:7px;">
144
+ Get your API Key and API Password from the profile page of your Sendabox.it account,
145
+ if you don't have one, you can <a href="https://www.sendabox.it" target="_blank">Sign Up</a> immediately.
146
+ </div>
147
+ ]]>
148
+ </comment>
149
+ <fields>
150
+ <!--<client>
151
+ <label>Client ID</label>
152
+ <frontend_type>text</frontend_type>
153
+ <sort_order>30</sort_order>
154
+ <frontend_model>sendabox_sendabox/adminhtml_system_config_form_field_required</frontend_model>
155
+ <backend_model>sendabox_sendabox/system_config_backend_form_field_required_text</backend_model>
156
+ <show_in_default>1</show_in_default>
157
+ <show_in_website>1</show_in_website>
158
+ <show_in_store>1</show_in_store>
159
+ </client>-->
160
+ <username translate="label">
161
+ <label>API Key</label>
162
+ <frontend_type>text</frontend_type>
163
+ <frontend_model>sendabox_sendabox/adminhtml_system_config_form_field_required</frontend_model>
164
+ <backend_model>sendabox_sendabox/system_config_backend_form_field_required_text</backend_model>
165
+ <sort_order>10</sort_order>
166
+ <show_in_default>1</show_in_default>
167
+ <show_in_website>1</show_in_website>
168
+ <show_in_store>1</show_in_store>
169
+ <comment><![CDATA[Insert "test" for a test of the extension]]></comment>
170
+ </username>
171
+ <password translate="label">
172
+ <label>API Password</label>
173
+ <frontend_type>password</frontend_type>
174
+ <frontend_model>sendabox_sendabox/adminhtml_system_config_form_field_required</frontend_model>
175
+ <backend_model>sendabox_sendabox/system_config_backend_form_field_required_text</backend_model>
176
+ <sort_order>20</sort_order>
177
+ <show_in_default>1</show_in_default>
178
+ <show_in_website>1</show_in_website>
179
+ <show_in_store>1</show_in_store>
180
+ <comment><![CDATA[Insert "test" for a test of the extension]]></comment>
181
+ </password>
182
+ <payment_type translate="label">
183
+ <label>Payment Type</label>
184
+ <frontend_type>label</frontend_type>
185
+ <sort_order>30</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
+ <comment><![CDATA[Please ensure you have sufficient credit in your Sendabox account]]></comment>
190
+ </payment_type>
191
+ <credits translate="label">
192
+ <label>Remaining Credits</label>
193
+ <frontend_type>text</frontend_type>
194
+ <sort_order>40</sort_order>
195
+ <show_in_default>1</show_in_default>
196
+ <show_in_website>1</show_in_website>
197
+ <show_in_store>1</show_in_store>
198
+ </credits>
199
+ </fields>
200
+ </general>
201
+ <!--<insurance translate="label">
202
+ <label>Insurance</label>
203
+ <frontend_type>text</frontend_type>
204
+ <sort_order>30</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
+ <fields>
209
+ <status translate="label">
210
+ <label>Insurance</label>
211
+ <frontend_type>select</frontend_type>
212
+ <frontend_model>sendabox_sendabox/adminhtml_system_config_form_field_insurance</frontend_model>
213
+ <sort_order>10</sort_order>
214
+ <source_model>sendabox_sendabox/system_config_source_insurance</source_model>
215
+ <show_in_default>1</show_in_default>
216
+ <show_in_website>1</show_in_website>
217
+ <show_in_store>1</show_in_store>
218
+ <comment>
219
+ <![CDATA[
220
+ Disabled - This option is unavailable to users.<br/>
221
+ Optional - The option is presented during checkout.<br/>
222
+ Mandatory - Insurance must be added to all orders.
223
+ ]]>
224
+ </comment>
225
+ </status>
226
+ </fields>
227
+ </insurance>-->
228
+ <pricing translate="label">
229
+ <label>Pricing</label>
230
+ <frontend_type>text</frontend_type>
231
+ <sort_order>20</sort_order>
232
+ <show_in_default>1</show_in_default>
233
+ <show_in_website>1</show_in_website>
234
+ <show_in_store>1</show_in_store>
235
+ <fields>
236
+ <method translate="label">
237
+ <label>Pricing Method</label>
238
+ <frontend_type>select</frontend_type>
239
+ <source_model>sendabox_sendabox/system_config_source_pricing</source_model>
240
+ <sort_order>10</sort_order>
241
+ <show_in_default>1</show_in_default>
242
+ <show_in_website>1</show_in_website>
243
+ <show_in_store>1</show_in_store>
244
+ <comment>
245
+ <![CDATA[
246
+ <strong>Free Shipping</strong> - no charge to customer.<br/>
247
+ <strong>Fixed Price / Flat Rate</strong> - customer always pays the amount set in "Shipping Price" below.<br/>
248
+ <strong>Dynamic Pricing</strong><br/>
249
+ - <strong>All</strong>: All quotes from carriers in "allowed carriers" are shown for the customer to choose from.<br/>
250
+ ]]>
251
+ </comment>
252
+ </method>
253
+ <shipping_fee translate="label">
254
+ <label>Shipping Price</label>
255
+ <frontend_type>text</frontend_type>
256
+ <sort_order>20</sort_order>
257
+ <show_in_default>1</show_in_default>
258
+ <show_in_website>1</show_in_website>
259
+ <show_in_store>1</show_in_store>
260
+ </shipping_fee>
261
+ <!-- <handling_fee translate="label">
262
+ <label>Handling Fee / Markup</label>
263
+ <frontend_type>text</frontend_type>
264
+ <sort_order>30</sort_order>
265
+ <show_in_default>1</show_in_default>
266
+ <show_in_website>1</show_in_website>
267
+ <show_in_store>1</show_in_store>
268
+ </handling_fee>
269
+ <handling_type translate="label">
270
+ <label>Handling Fee Calculation</label>
271
+ <frontend_type>select</frontend_type>
272
+ <source_model>shipping/source_handlingType</source_model>
273
+ <sort_order>40</sort_order>
274
+ <show_in_default>1</show_in_default>
275
+ <show_in_website>1</show_in_website>
276
+ <show_in_store>0</show_in_store>
277
+ </handling_type>-->
278
+ </fields>
279
+ </pricing>
280
+ <units translate="label">
281
+ <label>Units</label>
282
+ <frontend_type>text</frontend_type>
283
+ <sort_order>40</sort_order>
284
+ <show_in_default>1</show_in_default>
285
+ <show_in_website>1</show_in_website>
286
+ <show_in_store>1</show_in_store>
287
+ <fields>
288
+ <measure translate="label">
289
+ <label>Measure Unit</label>
290
+ <frontend_type>select</frontend_type>
291
+ <source_model>sendabox_sendabox/system_config_source_unit_measure</source_model>
292
+ <sort_order>10</sort_order>
293
+ <show_in_default>1</show_in_default>
294
+ <show_in_website>1</show_in_website>
295
+ <show_in_store>1</show_in_store>
296
+ <comment><![CDATA[The units used for product measurements]]></comment>
297
+ </measure>
298
+ <weight translate="label">
299
+ <label>Weight Unit</label>
300
+ <frontend_type>select</frontend_type>
301
+ <source_model>sendabox_sendabox/system_config_source_unit_weight</source_model>
302
+ <sort_order>20</sort_order>
303
+ <show_in_default>1</show_in_default>
304
+ <show_in_website>1</show_in_website>
305
+ <show_in_store>1</show_in_store>
306
+ <comment><![CDATA[The units used for product weights]]></comment>
307
+ </weight>
308
+ </fields>
309
+ </units>
310
+ <defaults translate="label">
311
+ <label>Packaging</label>
312
+ <frontend_type>text</frontend_type>
313
+ <sort_order>50</sort_order>
314
+ <show_in_default>1</show_in_default>
315
+ <show_in_website>1</show_in_website>
316
+ <show_in_store>1</show_in_store>
317
+ <comment><![CDATA[Default values will be used for all products that do not have product specific dimensions.]]></comment>
318
+ <fields>
319
+ <length translate="label">
320
+ <label>Length</label>
321
+ <frontend_model>sendabox_sendabox/adminhtml_system_config_form_field_required</frontend_model>
322
+ <frontend_type>text</frontend_type>
323
+ <sort_order>30</sort_order>
324
+ <show_in_default>1</show_in_default>
325
+ <show_in_website>1</show_in_website>
326
+ <show_in_store>1</show_in_store>
327
+ </length>
328
+ <width translate="label">
329
+ <label>Width</label>
330
+ <frontend_model>sendabox_sendabox/adminhtml_system_config_form_field_required</frontend_model>
331
+ <frontend_type>text</frontend_type>
332
+ <sort_order>40</sort_order>
333
+ <show_in_default>1</show_in_default>
334
+ <show_in_website>1</show_in_website>
335
+ <show_in_store>1</show_in_store>
336
+ </width>
337
+ <height translate="label">
338
+ <label>Height</label>
339
+ <frontend_model>sendabox_sendabox/adminhtml_system_config_form_field_required</frontend_model>
340
+ <frontend_type>text</frontend_type>
341
+ <sort_order>50</sort_order>
342
+ <show_in_default>1</show_in_default>
343
+ <show_in_website>1</show_in_website>
344
+ <show_in_store>1</show_in_store>
345
+ <comment><![CDATA[If unknown use 10x10x10]]></comment>
346
+ </height>
347
+ </fields>
348
+ </defaults>
349
+ <origin translate="label">
350
+ <label>Stock origin (warehouse) details</label>
351
+ <frontend_type>text</frontend_type>
352
+ <sort_order>80</sort_order>
353
+ <show_in_default>1</show_in_default>
354
+ <show_in_website>0</show_in_website>
355
+ <show_in_store>0</show_in_store>
356
+ <comment><![CDATA[Please enter the details of your pick-up location for all products.]]></comment>
357
+ <fields>
358
+ <contact_name translate="label">
359
+ <label>Name</label>
360
+ <frontend_type>text</frontend_type>
361
+ <frontend_model>sendabox_sendabox/adminhtml_system_config_form_field_required</frontend_model>
362
+ <backend_model>sendabox_sendabox/system_config_backend_form_field_required_text</backend_model>
363
+ <sort_order>10</sort_order>
364
+ <show_in_default>1</show_in_default>
365
+ <show_in_website>0</show_in_website>
366
+ <show_in_store>0</show_in_store>
367
+ </contact_name>
368
+ <contact_surname translate="label">
369
+ <label>Surname</label>
370
+ <frontend_type>text</frontend_type>
371
+ <frontend_model>sendabox_sendabox/adminhtml_system_config_form_field_required</frontend_model>
372
+ <backend_model>sendabox_sendabox/system_config_backend_form_field_required_text</backend_model>
373
+ <sort_order>20</sort_order>
374
+ <show_in_default>1</show_in_default>
375
+ <show_in_website>0</show_in_website>
376
+ <show_in_store>0</show_in_store>
377
+ </contact_surname>
378
+ <street translate="label">
379
+ <label>Street</label>
380
+ <frontend_type>text</frontend_type>
381
+ <frontend_model>sendabox_sendabox/adminhtml_system_config_form_field_required</frontend_model>
382
+ <backend_model>sendabox_sendabox/system_config_backend_form_field_required_text</backend_model>
383
+ <sort_order>30</sort_order>
384
+ <show_in_default>1</show_in_default>
385
+ <show_in_website>0</show_in_website>
386
+ <show_in_store>0</show_in_store>
387
+ </street>
388
+ <number translate="label">
389
+ <label>Number</label>
390
+ <frontend_type>text</frontend_type>
391
+ <frontend_model>sendabox_sendabox/adminhtml_system_config_form_field_required</frontend_model>
392
+ <backend_model>sendabox_sendabox/system_config_backend_form_field_required_text</backend_model>
393
+ <sort_order>40</sort_order>
394
+ <show_in_default>1</show_in_default>
395
+ <show_in_website>0</show_in_website>
396
+ <show_in_store>0</show_in_store>
397
+ </number>
398
+ <c_o translate="label">
399
+ <label>C/O</label>
400
+ <frontend_type>text</frontend_type>
401
+ <sort_order>50</sort_order>
402
+ <show_in_default>1</show_in_default>
403
+ <show_in_website>0</show_in_website>
404
+ <show_in_store>0</show_in_store>
405
+ </c_o>
406
+ <city translate="label">
407
+ <label>City</label>
408
+ <frontend_type>text</frontend_type>
409
+ <frontend_model>sendabox_sendabox/adminhtml_system_config_form_field_required</frontend_model>
410
+ <backend_model>sendabox_sendabox/system_config_backend_form_field_required_text</backend_model>
411
+ <sort_order>60</sort_order>
412
+ <show_in_default>1</show_in_default>
413
+ <show_in_website>0</show_in_website>
414
+ <show_in_store>0</show_in_store>
415
+ <comment>
416
+ <![CDATA[<div id="autocompleter_city_origin" class="ddl_city"></div>]]>
417
+ </comment>
418
+ </city>
419
+ <city_id translate="label">
420
+ <label>City Id</label>
421
+ <frontend_type>text</frontend_type>
422
+ <frontend_model>sendabox_sendabox/adminhtml_system_config_form_field_required</frontend_model>
423
+ <backend_model>sendabox_sendabox/system_config_backend_form_field_required_text</backend_model>
424
+ <sort_order>70</sort_order>
425
+ <show_in_default>1</show_in_default>
426
+ <show_in_website>0</show_in_website>
427
+ <show_in_store>0</show_in_store>
428
+ <comment><![CDATA[Inserted automatically after choosing the city. Do not modify it]]></comment>
429
+ </city_id>
430
+ <postcode translate="label">
431
+ <label>Postcode</label>
432
+ <frontend_type>text</frontend_type>
433
+ <frontend_model>sendabox_sendabox/adminhtml_system_config_form_field_required</frontend_model>
434
+ <backend_model>sendabox_sendabox/system_config_backend_form_field_required_text</backend_model>
435
+ <sort_order>80</sort_order>
436
+ <show_in_default>1</show_in_default>
437
+ <show_in_website>1</show_in_website>
438
+ <show_in_store>0</show_in_store>
439
+ <validate>validate-zip</validate>
440
+ </postcode>
441
+ <phone translate="label">
442
+ <label>Phone </label>
443
+ <frontend_type>text</frontend_type>
444
+ <frontend_model>sendabox_sendabox/adminhtml_system_config_form_field_required</frontend_model>
445
+ <backend_model>sendabox_sendabox/system_config_backend_form_field_required_text</backend_model>
446
+ <sort_order>90</sort_order>
447
+ <show_in_default>1</show_in_default>
448
+ <show_in_website>0</show_in_website>
449
+ <show_in_store>0</show_in_store>
450
+ </phone>
451
+ <email translate="label">
452
+ <label>Email</label>
453
+ <frontend_type>text</frontend_type>
454
+ <frontend_model>sendabox_sendabox/adminhtml_system_config_form_field_required</frontend_model>
455
+ <sort_order>100</sort_order>
456
+ <show_in_default>1</show_in_default>
457
+ <show_in_website>0</show_in_website>
458
+ <show_in_store>0</show_in_store>
459
+ <validate>validate-email</validate>
460
+ </email>
461
+ <notes translate="label">
462
+ <label>Notes</label>
463
+ <frontend_type>textarea</frontend_type>
464
+ <sort_order>110</sort_order>
465
+ <show_in_default>1</show_in_default>
466
+ <show_in_website>0</show_in_website>
467
+ <show_in_store>0</show_in_store>
468
+ <validate>validate-length maximum-length-60</validate>
469
+ <comment><![CDATA[Please, do not use more than 60 characters]]></comment>
470
+ </notes>
471
+ </fields>
472
+ </origin>
473
+ </groups>
474
+ </sendabox_options>
475
+ </sections>
476
+ </config>
app/code/community/Sendabox/Sendabox/sql/sendabox_sendabox_setup/mysql4-install-1.0.0.php ADDED
@@ -0,0 +1,205 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ set_time_limit(0);
4
+
5
+ /* @var $this Mage_Eav_Model_Entity_Setup */
6
+ /* @var $installer Mage_Eav_Model_Entity_Setup */
7
+
8
+ $installer = $this;
9
+ $installer->startSetup();
10
+
11
+ // Add custom Sendabox attributes
12
+ $installer->addAttributeGroup('catalog_product', 'Default', 'Sendabox', 99);
13
+
14
+ $installer->addAttribute('catalog_product', 'sendabox_length',
15
+ array(
16
+ 'type' => 'decimal',
17
+ 'label' => 'Length',
18
+ 'group' => 'Sendabox',
19
+ 'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_GLOBAL,
20
+ 'visible' => true,
21
+ 'required' => false,
22
+ 'user_defined' => false,
23
+ 'searchable' => false,
24
+ 'filterable' => false,
25
+ 'comparable' => false,
26
+ 'visible_on_front' => false,
27
+ 'unique' => false
28
+ )
29
+ );
30
+
31
+ $installer->addAttribute('catalog_product', 'sendabox_width',
32
+ array(
33
+ 'type' => 'decimal',
34
+ 'label' => 'Width',
35
+ 'group' => 'Sendabox',
36
+ 'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_GLOBAL,
37
+ 'visible' => true,
38
+ 'required' => false,
39
+ 'user_defined' => false,
40
+ 'searchable' => false,
41
+ 'filterable' => false,
42
+ 'comparable' => false,
43
+ 'visible_on_front' => false,
44
+ 'unique' => false
45
+ )
46
+ );
47
+
48
+ $installer->addAttribute('catalog_product', 'sendabox_height',
49
+ array(
50
+ 'type' => 'decimal',
51
+ 'label' => 'Height',
52
+ 'group' => 'Sendabox',
53
+ 'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_GLOBAL,
54
+ 'visible' => true,
55
+ 'required' => false,
56
+ 'user_defined' => false,
57
+ 'searchable' => false,
58
+ 'filterable' => false,
59
+ 'comparable' => false,
60
+ 'visible_on_front' => false,
61
+ 'unique' => false
62
+ )
63
+ );
64
+
65
+ // Create custom tables
66
+ $installer->run("
67
+ DROP TABLE IF EXISTS {$this->getTable('sendabox_shipment')};
68
+ CREATE TABLE {$this->getTable('sendabox_shipment')} (
69
+ `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT,
70
+ `order_id` int(10) UNSIGNED NOT NULL,
71
+ `status` int(10) NOT NULL DEFAULT '0',
72
+ `customer_selected_quote_id` bigint(20) UNSIGNED NULL DEFAULT NULL,
73
+ `customer_selected_quote_description` TEXT NOT NULL,
74
+ `admin_selected_quote_id` bigint(20) UNSIGNED NULL DEFAULT NULL,
75
+ `customer_cost` decimal(12,4) UNSIGNED NOT NULL,
76
+ `destination_name` varchar(250) NOT NULL,
77
+ `destination_surname` varchar(250) NOT NULL,
78
+ `destination_at` varchar(250),
79
+ `destination_street` varchar(250) NOT NULL,
80
+ `destination_number` varchar(250),
81
+ `destination_city` varchar(250) NOT NULL,
82
+ `destination_id` varchar(250),
83
+ `destination_postcode` varchar(250) NOT NULL,
84
+ `destination_phone` varchar(250),
85
+ `destination_email` varchar(250) NOT NULL,
86
+ `destination_note` varchar(250),
87
+ PRIMARY KEY (`id`)
88
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
89
+ ");
90
+
91
+
92
+ $installer->run("
93
+ DROP TABLE IF EXISTS {$this->getTable('sendabox_box')};
94
+ CREATE TABLE {$this->getTable('sendabox_box')} (
95
+ `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
96
+ `shipment_id` int(13) NOT NULL,
97
+ `comment` text NOT NULL,
98
+ `qty` int(11) NOT NULL DEFAULT '1',
99
+ `value` decimal(12,4) NOT NULL,
100
+ `measure_unit` varchar(255) NOT NULL,
101
+ `length` decimal(12,4) NOT NULL,
102
+ `width` decimal(12,4) NOT NULL,
103
+ `height` decimal(12,4) NOT NULL,
104
+ `weight_unit` varchar(255) NOT NULL,
105
+ `weight` decimal(12,4) NOT NULL,
106
+ PRIMARY KEY (`id`),
107
+ KEY `shipment_id` (`shipment_id`)
108
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
109
+ ");
110
+
111
+ $installer->run("
112
+ DROP TABLE IF EXISTS {$this->getTable('sendabox_quote')};
113
+ CREATE TABLE {$this->getTable('sendabox_quote')} (
114
+ `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT,
115
+ `magento_quote_id` int(10) UNSIGNED NOT NULL,
116
+ `carrier_id` int(13) UNSIGNED NOT NULL,
117
+ `accepted` boolean NOT NULL DEFAULT '0',
118
+ `total_price` decimal(12, 4) NOT NULL,
119
+ `base_price` decimal(12, 4) NOT NULL,
120
+ `tax` decimal(12, 4) NOT NULL,
121
+ `insurance_total_price` decimal(12, 4) NOT NULL,
122
+ `currency` varchar(10) NOT NULL,
123
+ `id_price` int(13) UNSIGNED NOT NULL,
124
+ `commercial_name` varchar(255) NOT NULL,
125
+ PRIMARY KEY (`id`),
126
+ INDEX (`carrier_id`)
127
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
128
+ ");
129
+
130
+ $installer->run("
131
+ DROP TABLE IF EXISTS {$this->getTable('sendabox_carrier')};
132
+ CREATE TABLE {$this->getTable('sendabox_carrier')} (
133
+ `id` int(13) UNSIGNED NOT NULL AUTO_INCREMENT,
134
+ `carrier_id` bigint(20) NOT NULL,
135
+ `company_name` varchar(250) NOT NULL,
136
+ PRIMARY KEY (`id`),
137
+ INDEX (`carrier_id`)
138
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
139
+
140
+ INSERT INTO {$this->getTable('sendabox_carrier')} (`id`, `carrier_id`, `company_name`) VALUES
141
+ (1, 2, 'Bartolini'),
142
+ (2, 6, 'SDA');
143
+ ");
144
+
145
+
146
+
147
+ $installer
148
+ ->getConnection()
149
+ ->addConstraint(
150
+ 'FK_QUOTE_CARRIER',
151
+ $installer->getTable('sendabox_quote'),
152
+ 'carrier_id',
153
+ $installer->getTable('sendabox_carrier'),
154
+ 'id',
155
+ 'cascade',
156
+ 'cascade'
157
+ );
158
+
159
+
160
+
161
+
162
+
163
+ // Insert a list of states into the regions database. Magento will then pick
164
+ // these up when displaying addresses and allow the user to select from a drop-down
165
+ // list, rather than having to type them in manually.
166
+ /*$regions = array(
167
+ array('code' => 'ACT', 'name' => 'Australia Capital Territory'),
168
+ array('code' => 'NSW', 'name' => 'New South Wales'),
169
+ array('code' => 'NT', 'name' => 'Northern Territory'),
170
+ array('code' => 'QLD', 'name' => 'Queensland'),
171
+ array('code' => 'SA', 'name' => 'South Australia'),
172
+ array('code' => 'TAS', 'name' => 'Tasmania'),
173
+ array('code' => 'VIC', 'name' => 'Victoria'),
174
+ array('code' => 'WA', 'name' => 'Western Australia')
175
+ );
176
+
177
+ $db = Mage::getSingleton('core/resource')->getConnection('core_read');
178
+
179
+ foreach ($regions as $region) {
180
+ // Check if this region has already been added
181
+ $result = $db->fetchOne("SELECT code FROM " . $this->getTable('directory_country_region') . " WHERE `country_id` = 'AU' AND `code` = '" . $region['code'] . "'");
182
+ if ($result != $region['code']) {
183
+ $installer->run(
184
+ "INSERT INTO `{$this->getTable('directory_country_region')}` (`country_id`, `code`, `default_name`) VALUES
185
+ ('AU', '" . $region['code'] . "', '" . $region['name'] . "');
186
+ INSERT INTO `{$this->getTable('directory_country_region_name')}` (`locale`, `region_id`, `name`) VALUES
187
+ ('en_US', LAST_INSERT_ID(), '" . $region['name'] . "'), ('en_AU', LAST_INSERT_ID(), '" . $region['name'] . "');"
188
+ );
189
+ }
190
+ }
191
+ */
192
+ /**Add foreign key to table. If FK with same name exist - it will be deleted
193
+ *
194
+ * @param string $fkName foreign key name
195
+ * @param string $tableName main table name
196
+ * @param string $keyName main table field name
197
+ * @param string $refTableName refered table name
198
+ * @param string $refKeyName refered table field name
199
+ * @param string $onUpdate on update statement
200
+ * @param string $onDelete on delete statement
201
+ * @param bool $purge
202
+ * @return mixed
203
+ */
204
+
205
+ $installer->endSetup();
app/design/adminhtml/default/default/layout/sendabox.xml ADDED
@@ -0,0 +1,36 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <layout>
3
+
4
+ <sendabox_adminhtml_shipment_index>
5
+
6
+ <reference name="content">
7
+ <block type="sendabox_sendabox/adminhtml_shipment">
8
+ <block type="sendabox_sendabox/adminhtml_shipment_grid" />
9
+ </block>
10
+ </reference>
11
+ </sendabox_adminhtml_shipment_index>
12
+
13
+ <sendabox_adminhtml_shipment_edit>
14
+ <reference name="head">
15
+ <action method="addCss"><stylesheet>sendabox/sendabox.css</stylesheet></action>
16
+ </reference>
17
+ <reference name="content">
18
+ <block type="sendabox_sendabox/adminhtml_shipment_edit" name="sendabox_shipment_edit" />
19
+ </reference>
20
+ <reference name="left">
21
+ <block type="sendabox_sendabox/adminhtml_shipment_edit_tabs" name="sendabox_shipment_edit_tabs">
22
+ <action method="addTab">
23
+ <name>sendabox_shipment_edit_tab_form</name>
24
+ <block>sendabox_sendabox/adminhtml_shipment_edit_tab_form</block>
25
+ </action>
26
+ </block>
27
+ </reference>
28
+ </sendabox_adminhtml_shipment_edit>
29
+
30
+ <adminhtml_system_config_edit>
31
+ <reference name="head">
32
+ <action method="addCss"><stylesheet>sendabox/sendabox.css</stylesheet></action>
33
+ <action method="addJs"><script>sendabox/autocomplete.js</script></action>
34
+ </reference>
35
+ </adminhtml_system_config_edit>
36
+ </layout>
app/etc/modules/Sendabox_Sendabox.xml ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <!--
3
+ /**
4
+ * Module initial config
5
+ *
6
+ * @author Italmondo S.p.a.
7
+ */
8
+ -->
9
+ <config>
10
+ <modules>
11
+ <Sendabox_Sendabox>
12
+ <active>true</active>
13
+ <codePool>community</codePool>
14
+ <depends>
15
+ <Mage_Shipping />
16
+ </depends>
17
+ </Sendabox_Sendabox>
18
+ </modules>
19
+ </config>
js/sendabox/autocomplete.js ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
1
+ window.onload = function() {var origin = document.getElementById('sendabox_options_origin_city');
2
+ if(origin!=null)
3
+ new Ajax.Autocompleter('sendabox_options_origin_city','autocompleter_city_origin','/CityOrigin.php', {paramName: 'destination_city',minChars: 3, afterUpdateElement : getSelectionIdOrigin});
4
+ }
5
+ function getSelectionIdOrigin(text, li) {
6
+ var city_id = document.getElementById("sendabox_options_origin_city_id").value = li.id;
7
+ }
package.xml ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <package>
3
+ <name>Sendabox_Sendabox</name>
4
+ <version>1.0.0</version>
5
+ <stability>stable</stability>
6
+ <license uri="http://opensource.org/licenses/osl-3.0.php">Open Software License (OSL)</license>
7
+ <channel>community</channel>
8
+ <extends/>
9
+ <summary>The extension provides two services: one as carrier and one as shipping management. Each service has its own configuration page reachable from the specific item added in the menu of the magento admin panel. There is also a page, still reachable from the menu, with the list of the orders that can be processed, each one with its own management page.</summary>
10
+ <description>The carrier service gets the quotes from the site sendabox.it which provides the quotes of some of the greatest carriers.&#xD;
11
+ In the configuration section of the carrier it is possible to enable/disable it, set a minimum order amount for free shipping and choose the allowed countries and carriers from the ones provided by sendabox.it.&#xD;
12
+ In the extension section of the system configuration page there are the settings to guarantee the extension to function properly:&#xD;
13
+ the login data of the sendabox account, the choice of the pricing method, the measure and weight units for the boxes to ship, the packaging default values, and the origin of the shipments.&#xD;
14
+ In the manage shipment page there is a list of the orders that can be processed by the extension and each one of them has its own page for the shipment management where you have to set the destination and the boxes to ship with the specific dimensions Then, after saving the changes, you can choose the shipment quote from the ones proposed and send the request of shipping to sendabox.it&#xD;
15
+ </description>
16
+ <notes>Version number: 1.0.0 Stability: Stable</notes>
17
+ <authors><author><name>Italmondo S.p.a.</name><user>Italmondo</user><email>magentosupport@sendabox.it</email></author></authors>
18
+ <date>2014-04-08</date>
19
+ <time>16:47:40</time>
20
+ <contents><target name="magecommunity"><dir name="Sendabox"><dir name="Sendabox"><dir name="Block"><dir name="Adminhtml"><dir name="Shipment"><dir name="Edit"><file name="Form.php" hash="b4d902cc166eb31b6e35b2bdc7331f4f"/><dir name="Tab"><file name="Abstract.php" hash="ebb8f83e8b17a3422ea047dc2ac2cf43"/><dir name="Form"><file name="Anywhere.php" hash="98c7ce21b8349babd176e57e2ba8fba3"/><file name="Boxes.php" hash="d3b10ca692f612edc0aa462b5edcbf97"/><file name="Products.php" hash="6e9d8d036a7e703575437e600b22cedb"/><file name="Quotes.php" hash="91f6c1fc6667676bfa47ce033c3237b3"/><file name="Status.php" hash="c3dab296bd89e472bcce74593f04061d"/></dir><file name="Form.php" hash="b5c4cce9b10e15ca2fb913bc7ba20d18"/></dir><file name="Tabs.php" hash="efa399d3761c18474a9a9fdc0fe1d2ef"/></dir><file name="Edit.php" hash="fd82eaf484043569ac628c138e4fbe96"/><file name="Grid.php" hash="6391583bb311ad88cd0155ac200888da"/></dir><file name="Shipment.php" hash="105b7e239a95b9ffc3445b2c7f263552"/><dir name="System"><dir name="Config"><dir name="Form"><dir name="Field"><file name="Required.php" hash="7935bc02781ac0a0927bbcfe223d25c5"/></dir><dir name="Fieldset"><file name="General.php" hash="cf999b29beaa075ac5713f630fa2f50f"/></dir></dir></dir></dir></dir></dir><dir name="Helper"><file name="Data.php" hash="578cdc7603dc8b5c13689defe120c67c"/></dir><dir name="Model"><file name="Box.php" hash="75843ccbe43474ff09d186530a9c91e0"/><file name="Carrier.php" hash="d79d2ef1a25ec8e0eb8a103e54f372f8"/><file name="Observer.php" hash="734dcf24b38d1c46b247a7a1eb2c5b20"/><file name="Quote.php" hash="fcb60a65289a4a16a4ebe56d52fe868f"/><dir name="Resource"><dir name="Box"><file name="Collection.php" hash="369c129a7475c54fd6b5f60b0a557921"/></dir><file name="Box.php" hash="116c8ae50a7e47a1ec311b32b5599522"/><dir name="Carrier"><file name="Collection.php" hash="1ee2d6e61e21764ee3b83fce3d5f8e92"/></dir><file name="Carrier.php" hash="03900b911f8ad844765c400ac05af44b"/><dir name="Quote"><file name="Collection.php" hash="312a840152ab0e80cc958c1c7e3f21e1"/></dir><file name="Quote.php" hash="ae9d39aeca2e97e09a20193f9617f528"/><dir name="Shipment"><file name="Collection.php" hash="9744be8c4244a939127c47a79373cf6f"/></dir><file name="Shipment.php" hash="c06ab95769cf1c5ed31c88a9dbc27e2f"/></dir><file name="Shipment.php" hash="7ce885cd83508d2a736693579688aa54"/><dir name="Shipping"><dir name="Carrier"><dir name="Sendabox"><dir name="Source"><file name="Method.php" hash="746879a722dc5ac517b5c6c8c99a9e09"/></dir></dir><file name="Sendabox.php" hash="9da79b03b4c3a6a08f9ce4d8abe892bc"/></dir></dir><dir name="System"><dir name="Config"><dir name="Backend"><dir name="Form"><dir name="Field"><dir name="Required"><file name="Text.php" hash="3031600b8b04fa6065cb91b2000a6bb8"/></dir></dir></dir></dir><dir name="Source"><file name="Errorprocess.php" hash="b264868a3655591a85a8f633984e5a25"/><file name="Insurance.php" hash="8a50ea3b78902566f526dbc8e5f7d6d9"/><file name="Pricing.php" hash="21c17624e7ceceef986dbb56115f3d5d"/><dir name="Shipment"><file name="Status.php" hash="cb3da45507a2e9dd7567b37fe97cfb82"/></dir><dir name="Unit"><file name="Measure.php" hash="f002813a46092805f5c6cd9a8e7dee09"/><file name="Weight.php" hash="f0995a3c58f1a87ba7d718daee49e568"/></dir><file name="Unit.php" hash="dd31ac8b2a1d26bfcd3929efd57a11c2"/></dir><file name="Source.php" hash="d753983ac45e38d7739023515ea284f4"/></dir></dir></dir><dir name="controllers"><dir name="Adminhtml"><file name="ShipmentController.php" hash="72afd2ae16458ec4fb07f2038f77d41e"/></dir></dir><dir name="etc"><file name="adminhtml.xml" hash="7400268460e2f9d273077c25ff04944d"/><file name="config.xml" hash="dcb8d4ef4219f06961cf85102eb0685b"/><file name="system.xml" hash="3841d0bbbdd88555afb3129cd4783f5f"/></dir><dir name="sql"><dir name="sendabox_sendabox_setup"><file name="mysql4-install-1.0.0.php" hash="e29438e67a8dabe5a24f9b9b6668042a"/></dir></dir></dir></dir></target><target name="magedesign"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="layout"><file name="sendabox.xml" hash="0ffd55d8b2ec22af645e5f911f6fdac2"/></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Sendabox_Sendabox.xml" hash="0d1ad52218d5906f77f5c77971e2ebeb"/></dir></target><target name="mageskin"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="sendabox"><file name="sendabox.css" hash="8f5e178cd5e4163770fcd4c6025d430f"/></dir></dir></dir></dir></target><target name="mage"><dir name="js"><dir name="sendabox"><file name="autocomplete.js" hash="83a5a9daf8526eac2e2b78dd98a45bc2"/></dir></dir><dir name="."><file name="CityOrigin.php" hash="31ebd027770221d00fa9e5c68f1527a6"/></dir></target></contents>
21
+ <compatible/>
22
+ <dependencies><required><php><min>5.3.0</min><max>6.0.0</max></php></required></dependencies>
23
+ </package>
skin/adminhtml/default/default/sendabox/sendabox.css ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ div.ddl_city {
2
+ position:absolute;
3
+ border:1px solid #888;
4
+ background-color: #fff;
5
+ z-index: 15;
6
+ margin:0;
7
+ padding:0;
8
+ }
9
+ div.ddl_city ul {
10
+ list-style-type:none;
11
+ margin:0;
12
+ padding:0;
13
+ }
14
+ div.ddl_city ul li.selected { background-color: #edf7fd;}
15
+ div.ddl_city ul li {
16
+ list-style-type:none;
17
+ display:block;
18
+ margin:0;
19
+ padding:2px;
20
+ line-height:1.5;
21
+ cursor:pointer;
22
+ }