dibagshipping - Version 0.1.0

Version Notes

Real-time shipping and delivery options from multiple Australian couriers, batch upload csv product dimension.

Download this release

Release Info

Developer Faisal Khalil
Extension dibagshipping
Version 0.1.0
Comparing to
See all releases


Version 0.1.0

Files changed (34) hide show
  1. app/code/local/Di/Bagshipping/Block/Adminhtml/Bagshipping.php +21 -0
  2. app/code/local/Di/Bagshipping/Block/Adminhtml/Bagshipping/Edit.php +54 -0
  3. app/code/local/Di/Bagshipping/Block/Adminhtml/Bagshipping/Edit/Form.php +29 -0
  4. app/code/local/Di/Bagshipping/Block/Adminhtml/Bagshipping/Edit/Tab/Form.php +57 -0
  5. app/code/local/Di/Bagshipping/Block/Adminhtml/Bagshipping/Edit/Tabs.php +33 -0
  6. app/code/local/Di/Bagshipping/Block/Adminhtml/Bagshipping/Grid.php +112 -0
  7. app/code/local/Di/Bagshipping/Block/Adminhtml/Ordergrid.php +20 -0
  8. app/code/local/Di/Bagshipping/Block/Adminhtml/Ordergrid/Grid.php +108 -0
  9. app/code/local/Di/Bagshipping/Block/Adminhtml/Renderer/Label.php +30 -0
  10. app/code/local/Di/Bagshipping/Block/Adminhtml/Signup.php +33 -0
  11. app/code/local/Di/Bagshipping/Block/Adminhtml/Signup/Form.php +28 -0
  12. app/code/local/Di/Bagshipping/Block/Adminhtml/Signup/Tab/Form.php +124 -0
  13. app/code/local/Di/Bagshipping/Block/Adminhtml/Signup/Tabs.php +30 -0
  14. app/code/local/Di/Bagshipping/Block/Bagshipping.php +25 -0
  15. app/code/local/Di/Bagshipping/Helper/Data.php +13 -0
  16. app/code/local/Di/Bagshipping/Model/Bagshipping.php +19 -0
  17. app/code/local/Di/Bagshipping/Model/Carrier/Customrate.php +214 -0
  18. app/code/local/Di/Bagshipping/Model/Mysql4/Bagshipping.php +18 -0
  19. app/code/local/Di/Bagshipping/Model/Mysql4/Bagshipping/Collection.php +24 -0
  20. app/code/local/Di/Bagshipping/Model/Mysql4/Order.php +18 -0
  21. app/code/local/Di/Bagshipping/Model/Mysql4/Order/Collection.php +18 -0
  22. app/code/local/Di/Bagshipping/Model/Mysql4/Owner.php +19 -0
  23. app/code/local/Di/Bagshipping/Model/Mysql4/Owner/Collection.php +20 -0
  24. app/code/local/Di/Bagshipping/Model/Observer.php +167 -0
  25. app/code/local/Di/Bagshipping/Model/Order.php +19 -0
  26. app/code/local/Di/Bagshipping/Model/Owner.php +19 -0
  27. app/code/local/Di/Bagshipping/controllers/Adminhtml/BagshippingController.php +258 -0
  28. app/code/local/Di/Bagshipping/controllers/Adminhtml/OwnerController.php +103 -0
  29. app/code/local/Di/Bagshipping/etc/config.xml +176 -0
  30. app/code/local/Di/Bagshipping/etc/system.xml +45 -0
  31. app/code/local/Di/Bagshipping/sql/bagshipping_setup/mysql4-install-0.1.0.php +65 -0
  32. app/design/adminhtml/default/default/layout/bagshipping.xml +20 -0
  33. app/etc/modules/Di_Bagshipping.xml +9 -0
  34. package.xml +24 -0
app/code/local/Di/Bagshipping/Block/Adminhtml/Bagshipping.php ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Baggage Freight Module
5
+ *
6
+ * @category DI
7
+ * @package DI_Bagshipping
8
+ * @author DI Dev Team
9
+ * @website http://www.di.net.au/
10
+ */
11
+ class Di_Bagshipping_Block_Adminhtml_Bagshipping extends Mage_Adminhtml_Block_Widget_Grid_Container {
12
+
13
+ public function __construct() {
14
+ $this->_controller = 'adminhtml_bagshipping';
15
+ $this->_blockGroup = 'bagshipping';
16
+ $this->_headerText = Mage::helper('bagshipping')->__('Product Manager');
17
+ $this->_addButtonLabel = Mage::helper('bagshipping')->__('Upload CSV');
18
+ parent::__construct();
19
+ }
20
+
21
+ }
app/code/local/Di/Bagshipping/Block/Adminhtml/Bagshipping/Edit.php ADDED
@@ -0,0 +1,54 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Baggage Freight Module
5
+ *
6
+ * @category DI
7
+ * @package DI_Bagshipping
8
+ * @author DI Dev Team
9
+ * @website http://www.di.net.au/
10
+ */
11
+
12
+ class Di_Bagshipping_Block_Adminhtml_Bagshipping_Edit extends Mage_Adminhtml_Block_Widget_Form_Container
13
+ {
14
+ public function __construct()
15
+ {
16
+ parent::__construct();
17
+
18
+ $this->_objectId = 'id';
19
+ $this->_blockGroup = 'bagshipping';
20
+ $this->_controller = 'adminhtml_bagshipping';
21
+
22
+ $this->_updateButton('save', 'label', Mage::helper('bagshipping')->__('Save File'));
23
+ $this->_updateButton('delete', 'label', Mage::helper('bagshipping')->__('Delete Item'));
24
+
25
+ $this->_addButton('saveandcontinue', array(
26
+ 'label' => Mage::helper('adminhtml')->__('Save And Continue Edit'),
27
+ 'onclick' => 'saveAndContinueEdit()',
28
+ 'class' => 'save',
29
+ ), -100);
30
+
31
+ $this->_formScripts[] = "
32
+ function toggleEditor() {
33
+ if (tinyMCE.getInstanceById('bagshipping_content') == null) {
34
+ tinyMCE.execCommand('mceAddControl', false, 'bagshipping_content');
35
+ } else {
36
+ tinyMCE.execCommand('mceRemoveControl', false, 'bagshipping_content');
37
+ }
38
+ }
39
+
40
+ function saveAndContinueEdit(){
41
+ editForm.submit($('edit_form').action+'back/edit/');
42
+ }
43
+ ";
44
+ }
45
+
46
+ public function getHeaderText()
47
+ {
48
+ if( Mage::registry('bagshipping_data') && Mage::registry('bagshipping_data')->getId() ) {
49
+ return Mage::helper('bagshipping')->__("Edit Item '%s'", $this->htmlEscape(Mage::registry('bagshipping_data')->getTitle()));
50
+ } else {
51
+ return Mage::helper('bagshipping')->__('Upload CSV file for package description ');
52
+ }
53
+ }
54
+ }
app/code/local/Di/Bagshipping/Block/Adminhtml/Bagshipping/Edit/Form.php ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Baggage Freight Module
5
+ *
6
+ * @category DI
7
+ * @package DI_Bagshipping
8
+ * @author DI Dev Team
9
+ * @website http://www.di.net.au/
10
+ */
11
+
12
+
13
+ class Di_Bagshipping_Block_Adminhtml_Bagshipping_Edit_Form extends Mage_Adminhtml_Block_Widget_Form {
14
+
15
+ protected function _prepareForm() {
16
+ $form = new Varien_Data_Form(array(
17
+ 'id' => 'edit_form',
18
+ 'action' => $this->getUrl('*/*/save', array('id' => $this->getRequest()->getParam('id'))),
19
+ 'method' => 'post',
20
+ 'enctype' => 'multipart/form-data'
21
+ )
22
+ );
23
+
24
+ $form->setUseContainer(true);
25
+ $this->setForm($form);
26
+ return parent::_prepareForm();
27
+ }
28
+
29
+ }
app/code/local/Di/Bagshipping/Block/Adminhtml/Bagshipping/Edit/Tab/Form.php ADDED
@@ -0,0 +1,57 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Baggage Freight Module
5
+ *
6
+ * @category DI
7
+ * @package DI_Bagshipping
8
+ * @author DI Dev Team
9
+ * @website http://www.di.net.au/
10
+ */
11
+
12
+ class Di_Bagshipping_Block_Adminhtml_Bagshipping_Edit_Tab_Form extends Mage_Adminhtml_Block_Widget_Form {
13
+
14
+ protected function _prepareForm() {
15
+ $form = new Varien_Data_Form();
16
+ $this->setForm($form);
17
+ $fieldset = $form->addFieldset('bagshipping_form', array('legend' => Mage::helper('bagshipping')->__('Product Information')));
18
+
19
+ $fieldset->addField('title', 'text', array(
20
+ 'label' => Mage::helper('bagshipping')->__('Title'),
21
+ 'class' => 'required-entry',
22
+ 'required' => true,
23
+ 'name' => 'title',
24
+ ));
25
+
26
+ $fieldset->addField('filename', 'file', array(
27
+ 'label' => Mage::helper('bagshipping')->__('File'),
28
+ 'required' => false,
29
+ 'name' => 'filename',
30
+ ));
31
+
32
+ $fieldset->addField('status', 'select', array(
33
+ 'label' => Mage::helper('bagshipping')->__('Status'),
34
+ 'name' => 'status',
35
+ 'values' => array(
36
+ array(
37
+ 'value' => 1,
38
+ 'label' => Mage::helper('bagshipping')->__('Enabled'),
39
+ ),
40
+ array(
41
+ 'value' => 2,
42
+ 'label' => Mage::helper('bagshipping')->__('Disabled'),
43
+ ),
44
+ ),
45
+ ));
46
+
47
+
48
+ if (Mage::getSingleton('adminhtml/session')->getBagshippingData()) {
49
+ $form->setValues(Mage::getSingleton('adminhtml/session')->getBagshippingData());
50
+ Mage::getSingleton('adminhtml/session')->setBagshippingData(null);
51
+ } elseif (Mage::registry('bagshipping_data')) {
52
+ $form->setValues(Mage::registry('bagshipping_data')->getData());
53
+ }
54
+ return parent::_prepareForm();
55
+ }
56
+
57
+ }
app/code/local/Di/Bagshipping/Block/Adminhtml/Bagshipping/Edit/Tabs.php ADDED
@@ -0,0 +1,33 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Baggage Freight Module
5
+ *
6
+ * @category DI
7
+ * @package DI_Bagshipping
8
+ * @author DI Dev Team
9
+ * @website http://www.di.net.au/
10
+ */
11
+
12
+ class Di_Bagshipping_Block_Adminhtml_Bagshipping_Edit_Tabs extends Mage_Adminhtml_Block_Widget_Tabs
13
+ {
14
+
15
+ public function __construct()
16
+ {
17
+ parent::__construct();
18
+ $this->setId('bagshipping_tabs');
19
+ $this->setDestElementId('edit_form');
20
+ $this->setTitle(Mage::helper('bagshipping')->__('Upload CSV file.'));
21
+ }
22
+
23
+ protected function _beforeToHtml()
24
+ {
25
+ $this->addTab('form_section', array(
26
+ 'label' => Mage::helper('bagshipping')->__('Upload CSV Information'),
27
+ 'title' => Mage::helper('bagshipping')->__('Upload CSV Information'),
28
+ 'content' => $this->getLayout()->createBlock('bagshipping/adminhtml_bagshipping_edit_tab_form')->toHtml(),
29
+ ));
30
+
31
+ return parent::_beforeToHtml();
32
+ }
33
+ }
app/code/local/Di/Bagshipping/Block/Adminhtml/Bagshipping/Grid.php ADDED
@@ -0,0 +1,112 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Baggage Freight Module
4
+ *
5
+ * @category DI
6
+ * @package DI_Bagshipping
7
+ * @author DI Dev Team
8
+ * @website http://www.di.net.au/
9
+ */
10
+
11
+ class Di_Bagshipping_Block_Adminhtml_Bagshipping_Grid extends Mage_Adminhtml_Block_Widget_Grid {
12
+
13
+ public function __construct() {
14
+ parent::__construct();
15
+ $this->setId('bagshippingGrid');
16
+ $this->setDefaultSort('bagshipping_id');
17
+ $this->setDefaultDir('ASC');
18
+ $this->setSaveParametersInSession(true);
19
+ }
20
+
21
+ protected function _prepareCollection() {
22
+ $collection = Mage::getModel('bagshipping/bagshipping')->getCollection();
23
+ $this->setCollection($collection);
24
+ return parent::_prepareCollection();
25
+ }
26
+
27
+ protected function _prepareColumns() {
28
+ $this->addColumn('bagshipping_id', array(
29
+ 'header' => Mage::helper('bagshipping')->__('ID'),
30
+ 'align' => 'right',
31
+ 'width' => '50px',
32
+ 'index' => 'bagshipping_id',
33
+ ));
34
+
35
+ $this->addColumn('pid', array(
36
+ 'header' => Mage::helper('bagshipping')->__('Product Id'),
37
+ 'align' => 'left',
38
+ 'index' => 'pid',
39
+ ));
40
+
41
+ $this->addColumn('sku', array(
42
+ 'header' => Mage::helper('bagshipping')->__('SKU'),
43
+ 'align' => 'left',
44
+ 'index' => 'sku',
45
+ ));
46
+
47
+ $this->addColumn('weight', array(
48
+ 'header' => Mage::helper('bagshipping')->__('Weight'),
49
+ 'align' => 'left',
50
+ 'index' => 'weight',
51
+ ));
52
+ $this->addColumn('height', array(
53
+ 'header' => Mage::helper('bagshipping')->__('Height'),
54
+ 'align' => 'left',
55
+ 'index' => 'height',
56
+ ));
57
+ $this->addColumn('width', array(
58
+ 'header' => Mage::helper('bagshipping')->__('Width'),
59
+ 'align' => 'left',
60
+ 'index' => 'width',
61
+ ));
62
+
63
+
64
+ $this->addColumn('length', array(
65
+ 'header' => Mage::helper('bagshipping')->__('Length'),
66
+ 'align' => 'left',
67
+ 'index' => 'length',
68
+ ));
69
+
70
+
71
+ $this->addColumn('action', array(
72
+ 'header' => Mage::helper('bagshipping')->__('Action'),
73
+ 'width' => '100',
74
+ 'type' => 'action',
75
+ 'getter' => 'getId',
76
+ 'actions' => array(
77
+ array(
78
+ 'caption' => Mage::helper('bagshipping')->__('Edit'),
79
+ 'url' => array('base' => '*/*/edit'),
80
+ 'field' => 'id'
81
+ )
82
+ ),
83
+ 'filter' => false,
84
+ 'sortable' => false,
85
+ 'index' => 'stores',
86
+ 'is_system' => true,
87
+ ));
88
+
89
+ $this->addExportType('*/*/exportCsv', Mage::helper('bagshipping')->__('CSV'));
90
+ $this->addExportType('*/*/exportXml', Mage::helper('bagshipping')->__('XML'));
91
+
92
+ return parent::_prepareColumns();
93
+ }
94
+
95
+ protected function _prepareMassaction() {
96
+ $this->setMassactionIdField('bagshipping_id');
97
+ $this->getMassactionBlock()->setFormFieldName('bagshipping');
98
+
99
+ $this->getMassactionBlock()->addItem('delete', array(
100
+ 'label' => Mage::helper('bagshipping')->__('Delete'),
101
+ 'url' => $this->getUrl('*/*/massDelete'),
102
+ 'confirm' => Mage::helper('bagshipping')->__('Are you sure?')
103
+ ));
104
+
105
+ return $this;
106
+ }
107
+
108
+ public function getRowUrl($row) {
109
+ return $this->getUrl('*/*/edit', array('id' => $row->getId()));
110
+ }
111
+
112
+ }
app/code/local/Di/Bagshipping/Block/Adminhtml/Ordergrid.php ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Baggage Freight Module
5
+ *
6
+ * @category DI
7
+ * @package DI_Bagshipping
8
+ * @author DI Dev Team
9
+ * @website http://www.di.net.au/
10
+ */
11
+ class Di_Bagshipping_Block_Adminhtml_Ordergrid extends Mage_Adminhtml_Block_Widget_Grid_Container {
12
+
13
+ public function __construct() {
14
+ $this->_controller = 'adminhtml_ordergrid';
15
+ $this->_blockGroup = 'bagshipping';
16
+ $this->_headerText = Mage::helper('bagshipping')->__('Order Manager');
17
+ parent::__construct();
18
+ }
19
+
20
+ }
app/code/local/Di/Bagshipping/Block/Adminhtml/Ordergrid/Grid.php ADDED
@@ -0,0 +1,108 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Baggage Freight Module
5
+ *
6
+ * @category DI
7
+ * @package DI_Bagshipping
8
+ * @author DI Dev Team
9
+ * @website http://www.di.net.au/
10
+ */
11
+
12
+ class Di_Bagshipping_Block_Adminhtml_Ordergrid_Grid extends Mage_Adminhtml_Block_Widget_Grid {
13
+
14
+ public function __construct() {
15
+ parent::__construct();
16
+ $this->setId('orderGrid');
17
+ $this->setDefaultSort('order_id');
18
+ $this->setDefaultDir('ASC');
19
+ $this->setSaveParametersInSession(true);
20
+ }
21
+
22
+ protected function _prepareCollection() {
23
+ $collection = Mage::getModel('bagshipping/order')->getCollection();
24
+ $this->setCollection($collection);
25
+ return parent::_prepareCollection();
26
+ }
27
+
28
+ protected function _prepareColumns() {
29
+ $this->addColumn('order_id', array(
30
+ 'header' => Mage::helper('bagshipping')->__('Id'),
31
+ 'align' => 'right',
32
+ 'width' => '50px',
33
+ 'index' => 'order_id',
34
+ ));
35
+
36
+ $this->addColumn('increment_id', array(
37
+ 'header' => Mage::helper('bagshipping')->__('Order Id'),
38
+ 'align' => 'right',
39
+ 'width' => '50px',
40
+ 'index' => 'increment_id',
41
+ ));
42
+
43
+ $this->addColumn('carrier', array(
44
+ 'header' => Mage::helper('bagshipping')->__('Carrier'),
45
+ 'align' => 'left',
46
+ 'index' => 'carrier',
47
+ ));
48
+
49
+ $this->addColumn('service', array(
50
+ 'header' => Mage::helper('bagshipping')->__('Service'),
51
+ 'align' => 'left',
52
+ 'index' => 'service',
53
+ ));
54
+
55
+ $this->addColumn('booking_price', array(
56
+ 'header' => Mage::helper('bagshipping')->__('Booking Price'),
57
+ 'align' => 'left',
58
+ 'index' => 'booking_price',
59
+ ));
60
+ $this->addColumn('shipping_price', array(
61
+ 'header' => Mage::helper('bagshipping')->__('Shipping Price'),
62
+ 'align' => 'left',
63
+ 'index' => 'shipping_price',
64
+ ));
65
+ $this->addColumn('user_id', array(
66
+ 'header' => Mage::helper('bagshipping')->__('User Id'),
67
+ 'align' => 'left',
68
+ 'index' => 'user_id',
69
+ ));
70
+
71
+
72
+ $this->addColumn('border_id', array(
73
+ 'header' => Mage::helper('bagshipping')->__('Baggage Freight Id'),
74
+ 'align' => 'left',
75
+ 'index' => 'border_id',
76
+ ));
77
+
78
+ $this->addColumn('label', array(
79
+ 'header' => 'Label',
80
+ 'index' => 'order_id',
81
+ 'renderer' => 'Di_Bagshipping_Block_Adminhtml_Renderer_Label'
82
+ ));
83
+
84
+
85
+
86
+ $this->addExportType('*/*/exportCsv', Mage::helper('bagshipping')->__('CSV'));
87
+ $this->addExportType('*/*/exportXml', Mage::helper('bagshipping')->__('XML'));
88
+
89
+ return parent::_prepareColumns();
90
+ }
91
+
92
+ protected function _prepareMassaction() {
93
+ $this->setMassactionIdField('bagshipping_id');
94
+ $this->getMassactionBlock()->setFormFieldName('bagshipping');
95
+
96
+ $this->getMassactionBlock()->addItem('delete', array(
97
+ 'label' => Mage::helper('bagshipping')->__('Delete'),
98
+ 'url' => $this->getUrl('*/*/massDelete'),
99
+ 'confirm' => Mage::helper('bagshipping')->__('Are you sure?')
100
+ ));
101
+ return $this;
102
+ }
103
+
104
+ public function getRowUrl($row) {
105
+ return $this->getUrl('*/*/edit', array('id' => $row->getId()));
106
+ }
107
+
108
+ }
app/code/local/Di/Bagshipping/Block/Adminhtml/Renderer/Label.php ADDED
@@ -0,0 +1,30 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Baggage Freight Module
5
+ *
6
+ * @category DI
7
+ * @package DI_Bagshipping
8
+ * @author DI Dev Team
9
+ * @website http://www.di.net.au/
10
+ */
11
+ class Di_Bagshipping_Block_Adminhtml_Renderer_Label extends Mage_Adminhtml_Block_Widget_Grid_Column_Renderer_Abstract {
12
+
13
+ public function render(Varien_Object $row) {
14
+ $value = $row->getData($this->getColumn()->getIndex());
15
+ $baggae_url = "http://www.baggagefreight.com.au/api/getLabel.aspx?orderid=" . $value['BOrderId'];
16
+ $reponse_code = file_get_contents($baggae_url);
17
+
18
+ $returnString = '';
19
+ if ($reponse_code == "0" || $reponse_code == "") {
20
+ $returnString = "N.A";
21
+ } else {
22
+ $returnString = '<a href = "http://www.baggagefreight.com.au/shipping-label/' . $reponse_code . '" target = "_blank">View Label</a>';
23
+ }
24
+
25
+ return $returnString;
26
+ }
27
+
28
+ }
29
+
30
+ ?>
app/code/local/Di/Bagshipping/Block/Adminhtml/Signup.php ADDED
@@ -0,0 +1,33 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Baggage Freight Module
5
+ *
6
+ * @category DI
7
+ * @package DI_Bagshipping
8
+ * @author DI Dev Team
9
+ * @website http://www.di.net.au/
10
+ */
11
+ class Di_Bagshipping_Block_Adminhtml_Signup extends Mage_Adminhtml_Block_Widget_Form_Container {
12
+
13
+ public function __construct() {
14
+ parent::__construct();
15
+
16
+ $this->_objectId = 'id';
17
+ $this->_blockGroup = 'bagshipping';
18
+ $this->_controller = 'adminhtml';
19
+ $this->_mode = 'signup';
20
+
21
+ $this->_updateButton('save', 'label', Mage::helper('bagshipping')->__('Store Owner Signup'));
22
+ }
23
+
24
+ public function getHeaderText() {
25
+
26
+ if (Mage::registry('owner_data') && Mage::registry('owner_data')->getOwnerId()) {
27
+ return Mage::helper('bagshipping')->__("Edit Owner's Data - '%s'", $this->htmlEscape(Mage::registry('owner_data')->getContactName()));
28
+ } else {
29
+ return Mage::helper('bagshipping')->__('Store Owner Setup');
30
+ }
31
+ }
32
+
33
+ }
app/code/local/Di/Bagshipping/Block/Adminhtml/Signup/Form.php ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Baggage Freight Module
5
+ *
6
+ * @category DI
7
+ * @package DI_Bagshipping
8
+ * @author DI Dev Team
9
+ * @website http://www.di.net.au/
10
+ */
11
+
12
+ class Di_Bagshipping_Block_Adminhtml_Signup_Form extends Mage_Adminhtml_Block_Widget_Form {
13
+
14
+ protected function _prepareForm() {
15
+ $form = new Varien_Data_Form(array(
16
+ 'id' => 'edit_form',
17
+ 'action' => $this->getUrl('*/*/save', array('id' => $this->getRequest()->getParam('id'))),
18
+ 'method' => 'post',
19
+ 'enctype' => 'multipart/form-data'
20
+ )
21
+ );
22
+
23
+ $form->setUseContainer(true);
24
+ $this->setForm($form);
25
+ return parent::_prepareForm();
26
+ }
27
+
28
+ }
app/code/local/Di/Bagshipping/Block/Adminhtml/Signup/Tab/Form.php ADDED
@@ -0,0 +1,124 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Baggage Freight Module
5
+ *
6
+ * @category DI
7
+ * @package DI_Bagshipping
8
+ * @author DI Dev Team
9
+ * @website http://www.di.net.au/
10
+ */
11
+
12
+ class Di_Bagshipping_Block_Adminhtml_Signup_Tab_Form extends Mage_Adminhtml_Block_Widget_Form {
13
+
14
+ protected function _prepareForm() {
15
+ $form = new Varien_Data_Form();
16
+ $this->setForm($form);
17
+ $fieldset = $form->addFieldset('owner_form', array('legend' => Mage::helper('bagshipping')->__('Store Owner Setup')));
18
+
19
+ $fieldset->addField('owner_id', 'hidden', array(
20
+ 'name' => 'owner_id',
21
+ ));
22
+
23
+ $fieldset->addField('contact_name', 'text', array(
24
+ 'label' => Mage::helper('bagshipping')->__('Contact Name'),
25
+ 'class' => 'required-entry',
26
+ 'required' => true,
27
+ 'name' => 'contact_name',
28
+ ));
29
+
30
+ $fieldset->addField('email', 'text', array(
31
+ 'label' => Mage::helper('bagshipping')->__('Storeowner Email'),
32
+ 'class' => 'required-entry',
33
+ 'required' => true,
34
+ 'name' => 'email',
35
+ ));
36
+
37
+ $fieldset->addField('password', 'password', array(
38
+ 'label' => Mage::helper('bagshipping')->__('Storeowner Password'),
39
+ 'class' => 'required-entry',
40
+ 'required' => true,
41
+ 'name' => 'password',
42
+ ));
43
+
44
+ $fieldset->addField('company', 'text', array(
45
+ 'label' => Mage::helper('bagshipping')->__('Collection Company'),
46
+ 'class' => 'required-entry',
47
+ 'required' => true,
48
+ 'name' => 'company',
49
+ ));
50
+
51
+ $fieldset->addField('collect_email', 'text', array(
52
+ 'label' => Mage::helper('bagshipping')->__('Collection Email Address'),
53
+ 'class' => 'required-entry',
54
+ 'required' => true,
55
+ 'name' => 'collect_email',
56
+ ));
57
+
58
+
59
+ $fieldset->addField('address', 'text', array(
60
+ 'label' => Mage::helper('bagshipping')->__('Collection Address'),
61
+ 'class' => 'required-entry',
62
+ 'required' => true,
63
+ 'name' => 'address',
64
+ ));
65
+
66
+
67
+ $fieldset->addField('address1', 'text', array(
68
+ 'label' => Mage::helper('bagshipping')->__('Collection Address'),
69
+ 'class' => 'required-entry',
70
+ 'required' => true,
71
+ 'name' => 'address1',
72
+ ));
73
+
74
+
75
+ $fieldset->addField('collect_country', 'text', array(
76
+ 'label' => Mage::helper('bagshipping')->__('Collection Country'),
77
+ 'class' => 'required-entry',
78
+ 'required' => true,
79
+ 'name' => 'collect_country',
80
+ ));
81
+
82
+
83
+ $fieldset->addField('collect_city', 'text', array(
84
+ 'label' => Mage::helper('bagshipping')->__('Collection City'),
85
+ 'class' => 'required-entry',
86
+ 'required' => true,
87
+ 'name' => 'collect_city',
88
+ ));
89
+
90
+
91
+ $fieldset->addField('collect_state', 'text', array(
92
+ 'label' => Mage::helper('bagshipping')->__('Collection State'),
93
+ 'class' => 'required-entry',
94
+ 'required' => true,
95
+ 'name' => 'collect_state',
96
+ ));
97
+
98
+
99
+ $fieldset->addField('collect_zip', 'text', array(
100
+ 'label' => Mage::helper('bagshipping')->__('Collection Zip'),
101
+ 'class' => 'required-entry',
102
+ 'required' => true,
103
+ 'name' => 'collect_zip',
104
+ ));
105
+
106
+
107
+ $fieldset->addField('collect_phno', 'text', array(
108
+ 'label' => Mage::helper('bagshipping')->__('Collection Phone'),
109
+ 'class' => 'required-entry',
110
+ 'required' => true,
111
+ 'name' => 'collect_phno',
112
+ ));
113
+
114
+
115
+ if (Mage::getSingleton('adminhtml/session')->getOwnerData()) {
116
+ $form->setValues(Mage::getSingleton('adminhtml/session')->getOwnerData());
117
+ Mage::getSingleton('adminhtml/session')->setOwnerData(null);
118
+ } elseif (Mage::registry('owner_data')) {
119
+ $form->setValues(Mage::registry('owner_data')->getData());
120
+ }
121
+ return parent::_prepareForm();
122
+ }
123
+
124
+ }
app/code/local/Di/Bagshipping/Block/Adminhtml/Signup/Tabs.php ADDED
@@ -0,0 +1,30 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Baggage Freight Module
5
+ *
6
+ * @category DI
7
+ * @package DI_Bagshipping
8
+ * @author DI Dev Team
9
+ * @website http://www.di.net.au/
10
+ */
11
+ class Di_Bagshipping_Block_Adminhtml_Signup_Tabs extends Mage_Adminhtml_Block_Widget_Tabs {
12
+
13
+ public function __construct() {
14
+ parent::__construct();
15
+ $this->setId('bagshipping_tabs');
16
+ $this->setDestElementId('edit_form');
17
+ $this->setTitle(Mage::helper('bagshipping')->__('Signup'));
18
+ }
19
+
20
+ protected function _beforeToHtml() {
21
+ $this->addTab('form_section', array(
22
+ 'label' => Mage::helper('bagshipping')->__('Sign-up for Bagshipping Account'),
23
+ 'title' => Mage::helper('bagshipping')->__('Sign-up for Bagshipping Account'),
24
+ 'content' => $this->getLayout()->createBlock('bagshipping/adminhtml_signup_tab_form')->toHtml(),
25
+ ));
26
+
27
+ return parent::_beforeToHtml();
28
+ }
29
+
30
+ }
app/code/local/Di/Bagshipping/Block/Bagshipping.php ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Baggage Freight Module
5
+ *
6
+ * @category DI
7
+ * @package DI_Bagshipping
8
+ * @author DI Dev Team
9
+ * @website http://www.di.net.au/
10
+ */
11
+
12
+ class Di_Bagshipping_Block_Bagshipping extends Mage_Core_Block_Template {
13
+
14
+ public function _prepareLayout() {
15
+ return parent::_prepareLayout();
16
+ }
17
+
18
+ public function getBagshipping() {
19
+ if (!$this->hasData('bagshipping')) {
20
+ $this->setData('bagshipping', Mage::registry('bagshipping'));
21
+ }
22
+ return $this->getData('bagshipping');
23
+ }
24
+
25
+ }
app/code/local/Di/Bagshipping/Helper/Data.php ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Baggage Freight Module
5
+ *
6
+ * @category DI
7
+ * @package DI_Bagshipping
8
+ * @author DI Dev Team
9
+ * @website http://www.di.net.au/
10
+ */
11
+ class Di_Bagshipping_Helper_Data extends Mage_Core_Helper_Abstract {
12
+
13
+ }
app/code/local/Di/Bagshipping/Model/Bagshipping.php ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Baggage Freight Module - Model
5
+ *
6
+ * @category DI
7
+ * @package DI_Bagshipping
8
+ * @author DI Dev Team
9
+ * @website http://www.di.net.au/
10
+ */
11
+
12
+ class Di_Bagshipping_Model_Bagshipping extends Mage_Core_Model_Abstract {
13
+
14
+ public function _construct() {
15
+ parent::_construct();
16
+ $this->_init('bagshipping/bagshipping');
17
+ }
18
+
19
+ }
app/code/local/Di/Bagshipping/Model/Carrier/Customrate.php ADDED
@@ -0,0 +1,214 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Di_Bagshipping_Model_Carrier_Customrate extends Mage_Shipping_Model_Carrier_Abstract implements Mage_Shipping_Model_Carrier_Interface {
4
+
5
+ protected $_code = 'bagshipping';
6
+ protected $_isFixed = true;
7
+
8
+ public function collectRates(Mage_Shipping_Model_Rate_Request $request) {
9
+
10
+ if (!$this->getConfigFlag('active')) {
11
+ return false;
12
+ }
13
+
14
+ $result = Mage::getModel('shipping/rate_result');
15
+
16
+ $method = Mage::getModel('shipping/rate_result_method');
17
+ $method->setCarrier('bagshipping');
18
+ $method->setCarrierTitle($this->getConfigData('title'));
19
+ $method->setMethod('bagshipping');
20
+ $method->setMethodTitle($this->getConfigData('name'));
21
+
22
+ $method1 = Mage::getModel('shipping/rate_result_method');
23
+ $method1->setCarrier('bagshipping');
24
+ $method1->setCarrierTitle($this->getConfigData('title'));
25
+ $method1->setMethod('bagshipping1');
26
+ $method1->setMethodTitle($this->getConfigData('name'));
27
+
28
+
29
+ $quote = Mage::getSingleton('checkout/session')->getQuote();
30
+
31
+ $shippingAddress = $quote->getShippingAddress();
32
+ $sName = $shippingAddress->getName();
33
+ $sCompany = $shippingAddress->getData("company");
34
+ $sStreet = $shippingAddress->getData("street");
35
+ $sPostcode = $shippingAddress->getData("postcode");
36
+ $sCity = $shippingAddress->getData("city");
37
+ $sRegionCode = $shippingAddress->getRegionCode();
38
+ $sRegion = $shippingAddress->getRegion();
39
+ $sCountry = $shippingAddress->getCountry();
40
+ $sCountryModelName = $shippingAddress->getCountryModel()->getName();
41
+
42
+
43
+ $cartItems = $quote->getAllVisibleItems();
44
+ $weight = 0;
45
+ $name['baggage'] = array();
46
+ $cartGrossTotal = 0;
47
+
48
+
49
+ foreach ($cartItems as $item) {
50
+ $quantity = $item->getQty();
51
+ $weightPerItem = $item->getWeight();
52
+ $weight += ($item->getWeight() * $item->getQty());
53
+
54
+ for ($i = 1; $i <= $item->getQty(); $i++) {
55
+ $name['baggage'][] = $item->getName();
56
+ $unitPrice['baggage'][] = $item->getPrice();
57
+ $sku['baggage'][] = $item->getSku();
58
+ $ids['baggage'][] = $item->getProductId();
59
+ $qty['baggage'][] = $item->getQty();
60
+ // $weight['baggage'][] = $item->getWeight();
61
+ $cal_unit['baggage'][] = 'cm';
62
+ }
63
+ $cal_weight['baggage'][] = $item->getWeight() * $item->getQty();
64
+ $cartGrossTotal += $item->getPriceInclTax() * $item->getQty();
65
+
66
+ //get the data from excel file database if there
67
+
68
+ $bProduct = Mage::getModel('bagshipping/bagshipping')->getCollection()->addProductFilter($item->getProductId());
69
+ $mItem = $bProduct->getFirstItem();
70
+
71
+ for ($i = 1; $i <= $item->getQty(); $i++) {
72
+ if (count($mItem) > 0) {
73
+ if (!($mItem->getData('length'))) {
74
+ $excel_length['baggage'][] = 0;
75
+ } else {
76
+ $excel_length['baggage'][] = $mItem->getData('length');
77
+ }
78
+ if (!($mItem->getData('width'))) {
79
+ $excel_width['baggage'][] = 0;
80
+ } else {
81
+ $excel_width['baggage'][] = $mItem->getData('width');
82
+ }
83
+ if (!($mItem->getData('height'))) {
84
+ $excel_height['baggage'][] = 0;
85
+ } else {
86
+ $excel_height['baggage'][] = $mItem->getData('height');
87
+ }
88
+
89
+ if (!($mItem->getData('weight'))) {
90
+ $excel_weight['baggage'][] = $item->getWeight();
91
+ } else {
92
+ $excel_weight['baggage'][] = $mItem->getData('weight');
93
+ }
94
+ } else {
95
+ $excel_weight['baggage'][] = $item->getWeight();
96
+ $excel_height['baggage'][] = 0;
97
+ $excel_width['baggage'][] = 0;
98
+ $excel_length['baggage'][] = 0;
99
+ }
100
+ }
101
+ } //end of foreach
102
+
103
+
104
+ $urlWeight = implode(',', $excel_weight['baggage']);
105
+ $urlLength = implode(',', $excel_length['baggage']);
106
+ $urlWidth = implode(',', $excel_width['baggage']);
107
+ $urlHeight = implode(',', $excel_height['baggage']);
108
+ $urlUnit = implode(',', $cal_unit['baggage']);
109
+ $cartSku = implode(',', $sku['baggage']);
110
+ $urlAmount = $cartGrossTotal;
111
+
112
+
113
+ //get the store owner information for collection information
114
+
115
+ $store_owner_info = Mage::getModel('bagshipping/owner')->getCollection();
116
+ $owner = $store_owner_info->getFirstItem();
117
+
118
+ $cCountry = $owner->getData('collect_country');
119
+ $cState = $owner->getData('collect_state');
120
+ $cCity = $owner->getData('collect_city');
121
+ $cPin = $owner->getData('collect_zip');
122
+
123
+
124
+
125
+
126
+ $data = array('cCountry' => $cCountry,
127
+ 'cState' => $cState,
128
+ 'cCity' => $cCity,
129
+ 'cPin' => $cPin,
130
+ 'dCountry' => $sCountryModelName,
131
+ 'dState' => $sRegionCode,
132
+ 'dCity' => $sCity,
133
+ 'dPin' => $sPostcode,
134
+ 'Weight' => $urlWeight,
135
+ 'Length' => $urlLength,
136
+ 'Width' => $urlWidth,
137
+ 'Height' => $urlHeight,
138
+ 'Unit' => $urlUnit,
139
+ 'Amount' => $urlAmount,
140
+ );
141
+
142
+
143
+
144
+
145
+ $ch = curl_init('http://www.baggagefreight.com.au/api/minrate.aspx');
146
+ curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
147
+ curl_setopt($ch, CURLOPT_POST, 1);
148
+ curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
149
+ curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
150
+
151
+ $value = curl_exec($ch);
152
+
153
+
154
+
155
+ curl_close($ch);
156
+ $shipvalues = explode(':', $value);
157
+
158
+ //keping all the req information in the seiion
159
+
160
+ Mage::getSingleton('core/session')->setMyFullShipDetails($value);
161
+ Mage::getSingleton('core/session')->setArrWeight($urlWeight);
162
+ Mage::getSingleton('core/session')->setArrLength($urlLength);
163
+ Mage::getSingleton('core/session')->setArrWidth($urlWidth);
164
+ Mage::getSingleton('core/session')->setArrHeight($urlHeight);
165
+ Mage::getSingleton('core/session')->setArrUnit($urlUnit);
166
+ Mage::getSingleton('core/session')->setStrDescription($cartSku);
167
+
168
+
169
+ $carrier = $shipvalues[1];
170
+ $service = $shipvalues[2];
171
+ $transit = $shipvalues[4];
172
+ $arrTransit = explode(" ",$transit);
173
+ $transit = $arrTransit[0];
174
+ $warranty = $shipvalues[5];
175
+ $show_ship_cost = $shipvalues[0];
176
+
177
+ $cost_with_warranty = floatval($show_ship_cost)+floatval($warranty);
178
+
179
+ Mage::getSingleton('core/session')->setBfShipCost($shipvalues[0]);
180
+ Mage::getSingleton('core/session')->setBfWarranty($warranty);
181
+ Mage::getSingleton('core/session')->setBfTransit($transit);
182
+ Mage::getSingleton('core/session')->setBfCarrier($carrier);
183
+ Mage::getSingleton('core/session')->setBfService($service);
184
+
185
+ $show_carrier_1 = $carrier."[".$service."] ( Without Transit Warranty )";
186
+ $show_carrier_2 = $carrier."[".$service."] ( With Transit Warranty )";
187
+
188
+ $method->setPrice($show_ship_cost);
189
+ $method->setCost(2);
190
+
191
+ $method->setCarrierTitle($carrier);
192
+ $method->setMethodTitle($show_carrier_1);
193
+
194
+ $result->append($method);
195
+
196
+ if(floatval($warranty)>0)
197
+ {
198
+ $method1->setPrice($cost_with_warranty);
199
+ $method1->setCost(2);
200
+
201
+ $method1->setCarrierTitle($carrier);
202
+ $method1->setMethodTitle($show_carrier_2);
203
+
204
+ $result->append($method1);
205
+ }
206
+
207
+ return $result;
208
+ }
209
+
210
+ public function getAllowedMethods() {
211
+ return array('bagshipping' => $this->getConfigData('name'));
212
+ }
213
+
214
+ }
app/code/local/Di/Bagshipping/Model/Mysql4/Bagshipping.php ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Baggage Freight Module
5
+ *
6
+ * @category DI
7
+ * @package DI_Bagshipping
8
+ * @author DI Dev Team
9
+ * @website http://www.di.net.au/
10
+ */
11
+ class Di_Bagshipping_Model_Mysql4_Bagshipping extends Mage_Core_Model_Mysql4_Abstract {
12
+
13
+ public function _construct() {
14
+ $this->_init('bagshipping/bagshipping', 'bagshipping_id');
15
+ }
16
+
17
+
18
+ }
app/code/local/Di/Bagshipping/Model/Mysql4/Bagshipping/Collection.php ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Baggage Freight Module
5
+ *
6
+ * @category DI
7
+ * @package DI_Bagshipping
8
+ * @author DI Dev Team
9
+ * @website http://www.di.net.au/
10
+ */
11
+ class Di_Bagshipping_Model_Mysql4_Bagshipping_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract {
12
+
13
+ public function _construct() {
14
+ parent::_construct();
15
+ $this->_init('bagshipping/bagshipping');
16
+ }
17
+
18
+ public function addProductFilter($productId) {
19
+ $this->getSelect()
20
+ ->where('pid = ?', $productId);
21
+ return $this;
22
+ }
23
+
24
+ }
app/code/local/Di/Bagshipping/Model/Mysql4/Order.php ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Baggage Freight Module
5
+ *
6
+ * @category DI
7
+ * @package DI_Bagshipping
8
+ * @author DI Dev Team
9
+ * @website http://www.di.net.au/
10
+ */
11
+
12
+ class Di_Bagshipping_Model_Mysql4_Order extends Mage_Core_Model_Mysql4_Abstract {
13
+
14
+ public function _construct() {
15
+ $this->_init('bagshipping/order', 'order_id');
16
+ }
17
+
18
+ }
app/code/local/Di/Bagshipping/Model/Mysql4/Order/Collection.php ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Baggage Freight Module
5
+ *
6
+ * @category DI
7
+ * @package DI_Bagshipping
8
+ * @author DI Dev Team
9
+ * @website http://www.di.net.au/
10
+ */
11
+ class Di_Bagshipping_Model_Mysql4_Order_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract {
12
+
13
+ public function _construct() {
14
+ parent::_construct();
15
+ $this->_init('bagshipping/order');
16
+ }
17
+
18
+ }
app/code/local/Di/Bagshipping/Model/Mysql4/Owner.php ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Baggage Freight Module
5
+ *
6
+ * @category DI
7
+ * @package DI_Bagshipping
8
+ * @author DI Dev Team
9
+ * @website http://www.di.net.au/
10
+ */
11
+
12
+
13
+ class Di_Bagshipping_Model_Mysql4_Owner extends Mage_Core_Model_Mysql4_Abstract {
14
+
15
+ public function _construct() {
16
+ $this->_init('bagshipping/owner', 'owner_id');
17
+ }
18
+
19
+ }
app/code/local/Di/Bagshipping/Model/Mysql4/Owner/Collection.php ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Baggage Freight Module
5
+ *
6
+ * @category DI
7
+ * @package DI_Bagshipping
8
+ * @author DI Dev Team
9
+ * @website http://www.di.net.au/
10
+ */
11
+
12
+
13
+ class Di_Bagshipping_Model_Mysql4_Owner_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract {
14
+
15
+ public function _construct() {
16
+ parent::_construct();
17
+ $this->_init('bagshipping/owner');
18
+ }
19
+
20
+ }
app/code/local/Di/Bagshipping/Model/Observer.php ADDED
@@ -0,0 +1,167 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Di_Bagshipping_Model_Observer {
4
+
5
+ public function saveOrderinBagshipping($observer) {
6
+
7
+ $orderId = (int)current($observer->getEvent()->getOrderIds());
8
+ $order = null;
9
+ if($orderId){
10
+ $oOrder = Mage::getModel('sales/order')->load($orderId);
11
+ } else {
12
+ $incrementId = Mage::getSingleton('checkout/session')->getLastRealOrderId();
13
+ $oOrder = Mage::getModel('sales/order')->loadByIncrementId($incrementId);
14
+ }
15
+
16
+
17
+ $shipping_method = $oOrder->getShippingMethod();
18
+ $special_instruction = $oOrder->getCustomerNote();
19
+
20
+ if($shipping_method=="bagshipping_bagshipping" || $shipping_method=="bagshipping_bagshipping1")
21
+ {
22
+ $_totalData =$oOrder->getData();
23
+ $shipping_address = $_totalData['shipping_address_id'];
24
+ $address = Mage::getModel('sales/order_address')->load($shipping_address);
25
+
26
+
27
+ $base_subtotal = $_totalData['base_subtotal'];
28
+ $base_grand_total = $_totalData['base_grand_total'];
29
+ $base_shipping_amount = Mage::getSingleton('core/session')->getBfShipCost();
30
+
31
+
32
+ $collection = Mage::getModel('bagshipping/owner')->getCollection();
33
+ $id = $collection->getFirstItem()->getOwnerId();
34
+ $model = Mage::getModel('bagshipping/owner')->load($id);
35
+
36
+
37
+ /*
38
+ $resource = Mage::getSingleton('core/resource');
39
+ $readConnection = $resource->getConnection('core_read');
40
+ $table = $resource->getTableName('bagshipping/storeowner');
41
+ $write = Mage::getSingleton('core/resource');
42
+ $writeConnection = $resource->getConnection('core_write');
43
+ $table_excel = $resource->getTableName('bagshipping/excel');
44
+ $table_order = $resource->getTableName('bagshipping/order');
45
+ $sql = "SELECT * FROM $table LIMIT 1";
46
+ //$data = Mage::getSingleton('core/resource')->getConnection('core_read')->fetchAll($sql);
47
+ */
48
+
49
+
50
+
51
+ $Country_name = $model->getData('collect_country');
52
+ $strCollectCompany = $model->getData('company');
53
+ $strCollContactName = $model->getData('contact_name');
54
+ $strCollectAddress = $model->getData('address');
55
+ $strCollectAddress1 = $model->getData('address1');
56
+ $strCollectCity = $model->getData('collect_city');
57
+ $strCollectState = $model->getData('collect_state');
58
+ $strCollectZip = $model->getData('collect_zip');
59
+ $strCollectEmail = $model->getData('collect_email');
60
+ $strCollectPhNo = $model->getData('collect_phno');
61
+ $strEmail = $model->getData('email');
62
+ $strPassword = $model->getData('password');
63
+ $strCollectCountry = $Country_name;
64
+ $strUrl = $_SERVER['HTTP_HOST'];
65
+
66
+
67
+
68
+
69
+ $strDestContactName = $address->getData('firstname')." ".$address->getData('lastname');
70
+ $strDestEmail = $address->getData('email');
71
+ $strDestPhNo = $address->getData('telephone');
72
+ $strDestCompany = $address->getData('company');
73
+ $strDestAddress = $address->getData('street');
74
+ $strDestAddress1 = '';
75
+
76
+ $strDestCity = $address->getData('city');
77
+ $strDestState = $address->getRegionCode();
78
+ $strDestZip = $address->getData('postcode');
79
+ $strDestCountry = $address->getCountryModel()->getName();
80
+ $address->getData('street');
81
+
82
+ $Data = Mage::getSingleton('core/session')->getMyFullShipDetails();
83
+ $urlWeight = Mage::getSingleton('core/session')->getArrWeight();
84
+ $urlLength = Mage::getSingleton('core/session')->getArrLength();
85
+ $urlWidth = Mage::getSingleton('core/session')->getArrWidth();
86
+ $urlHeight = Mage::getSingleton('core/session')->getArrHeight();
87
+ $urlUnit = Mage::getSingleton('core/session')->getArrUnit();
88
+ $strDescription = Mage::getSingleton('core/session')->getStrDescription();
89
+ $value = explode(':',$Data);
90
+
91
+ if($shipping_method=="bagshipping_bagshipping")
92
+ {
93
+ $coverCost = 0.00;
94
+ }
95
+ else
96
+ {
97
+ $coverCost = floatval(Mage::getSingleton('core/session')->getBfWarranty());
98
+ }
99
+
100
+ $strTransitTime = Mage::getSingleton('core/session')->getBfTransit();
101
+
102
+
103
+
104
+ $data = array(
105
+ 'strInvoiceNumber' => $oOrder->getIncrementId(),
106
+ 'strCarrier' => $value[1],
107
+ 'strService' => $value[2],
108
+ 'strTotalBookingRate' => $base_subtotal,
109
+ 'strBookingAmount' => $base_shipping_amount,
110
+ 'special_instruction' => $special_instruction,
111
+ 'strCollectCompany' => $strCollectCompany,
112
+ 'strCollContactName' => $strCollContactName,
113
+ 'strCollectAddress' => $strCollectAddress,
114
+ 'strCollectAddress1' => $strCollectAddress1,
115
+ 'strCollectCity' => $strCollectCity,
116
+ 'strCollectState' => $strCollectState,
117
+ 'strCollectZip' => $strCollectZip,
118
+ 'strCollectCountry' => $strCollectCountry,
119
+ 'strCollectEmail' => $strCollectEmail,
120
+ 'strCollectPhNo' => $strCollectPhNo,
121
+ 'strEmail' => $strEmail,
122
+ 'strPassword' => $strPassword,
123
+ 'strDestContactName' => $strDestContactName,
124
+ 'strDestEmail' => $strDestEmail,
125
+ 'strDestPhNo' => $strDestPhNo,
126
+ 'strDestCompany' => $strDestCompany,
127
+ 'strDestAddress' => $strDestAddress,
128
+ 'strDestAddress1' => $strDestAddress1,
129
+ 'strDestCity' => $strDestCity,
130
+ 'strDestState' => $strDestState,
131
+ 'strDestZip' => $strDestZip,
132
+ 'strDestCountry' => $strDestCountry,
133
+ 'coverCost' => $coverCost,
134
+ 'strTransitTime' => $value[5],
135
+ 'strDescription' => $strDescription,
136
+ 'arrWeight' => $urlWeight,
137
+ 'arrLength' => $urlLength,
138
+ 'arrWidth' => $urlWidth,
139
+ 'arrHeight' => $urlHeight,
140
+ 'arrUnit' => $urlUnit,
141
+ 'strUrl' => $strUrl
142
+ );
143
+
144
+
145
+ $ch = curl_init('http://www.baggagefreight.com.au/api/doBooking.aspx');
146
+ curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
147
+ curl_setopt($ch, CURLOPT_POST, 1);
148
+ curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
149
+ curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
150
+ $result = curl_exec($ch);
151
+
152
+ $user_id = Mage::helper('customer')->getCustomer()->getId();
153
+ if($result>0)
154
+ {
155
+ $order = Mage::getModel('bagshipping/order');
156
+ $order->setData('increment_id',$oOrder->getIncrementId());
157
+ $order->setData('carrier',$value[1]);
158
+ $order->setData('service',$value[2]);
159
+ $order->setData('booking_price',$base_grand_total);
160
+ $order->setData('shipping_price',$base_shipping_amount);
161
+ $order->setData('user_id',$user_id);
162
+ $order->setData('border_id',$result);
163
+ $order->save();
164
+ }
165
+ }
166
+ }
167
+ }
app/code/local/Di/Bagshipping/Model/Order.php ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Baggage Freight Module - Order Model
5
+ *
6
+ * @category DI
7
+ * @package DI_Bagshipping
8
+ * @author DI Dev Team
9
+ * @website http://www.di.net.au/
10
+ */
11
+
12
+ class Di_Bagshipping_Model_Order extends Mage_Core_Model_Abstract {
13
+
14
+ public function _construct() {
15
+ parent::_construct();
16
+ $this->_init('bagshipping/order');
17
+ }
18
+
19
+ }
app/code/local/Di/Bagshipping/Model/Owner.php ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Baggage Freight Module - Owner Model
5
+ *
6
+ * @category DI
7
+ * @package DI_Bagshipping
8
+ * @author DI Dev Team
9
+ * @website http://www.di.net.au/
10
+ */
11
+
12
+ class Di_Bagshipping_Model_Owner extends Mage_Core_Model_Abstract {
13
+
14
+ public function _construct() {
15
+ parent::_construct();
16
+ $this->_init('bagshipping/owner');
17
+ }
18
+
19
+ }
app/code/local/Di/Bagshipping/controllers/Adminhtml/BagshippingController.php ADDED
@@ -0,0 +1,258 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Baggage Freight Module - Controller
5
+ *
6
+ * @category DI
7
+ * @package Di_Bagshipping
8
+ * @author DI Dev Team
9
+ * @website http://www.di.net.au/
10
+ */
11
+
12
+ class Di_Bagshipping_Adminhtml_BagshippingController extends Mage_Adminhtml_Controller_action {
13
+
14
+ protected function _initAction() {
15
+ $this->loadLayout()
16
+ ->_setActiveMenu('bagshipping/items')
17
+ ->_addBreadcrumb(Mage::helper('adminhtml')->__('Items Manager'), Mage::helper('adminhtml')->__('Item Manager'));
18
+
19
+ return $this;
20
+ }
21
+
22
+ public function indexAction() {
23
+ $this->_initAction()
24
+ ->renderLayout();
25
+ }
26
+
27
+ public function ordergridAction() {
28
+
29
+ $this->_initAction()
30
+ ->renderLayout();
31
+ }
32
+
33
+ public function viewordersAction() {
34
+ $owner = Mage::getModel('bagshipping/owner')->getCollection();
35
+ $own = $owner->getFirstItem();
36
+ if ($own):
37
+ $email = $own->getEmail();
38
+ $password = $own->getPassword();
39
+ $url = "http://www.baggagefreight.com.au/api/authloginstore.aspx?username=" . $email . "&password=" . $password;
40
+ $this->_redirectUrl($url);
41
+ else:
42
+ Mage::getSingleton('adminhtml/session')->addError(Mage::helper('bagshipping')->__('Error! You have not configured Baggage Freight account.'));
43
+ $this->_redirect('*/*/');
44
+ endif;
45
+ }
46
+
47
+ public function editAction() {
48
+ $id = $this->getRequest()->getParam('id');
49
+ $model = Mage::getModel('bagshipping/bagshipping')->load($id);
50
+
51
+ if ($model->getId() || $id == 0) {
52
+ $data = Mage::getSingleton('adminhtml/session')->getFormData(true);
53
+ if (!empty($data)) {
54
+ $model->setData($data);
55
+ }
56
+ Mage::register('bagshipping_data', $model);
57
+
58
+ $this->loadLayout();
59
+ $this->_setActiveMenu('bagshipping/items');
60
+
61
+ $this->_addBreadcrumb(Mage::helper('adminhtml')->__('Product Manager'), Mage::helper('adminhtml')->__('Item Manager'));
62
+
63
+ $this->getLayout()->getBlock('head')->setCanLoadExtJs(true);
64
+
65
+ $this->_addContent($this->getLayout()->createBlock('bagshipping/adminhtml_bagshipping_edit'))
66
+ ->_addLeft($this->getLayout()->createBlock('bagshipping/adminhtml_bagshipping_edit_tabs'));
67
+
68
+ $this->renderLayout();
69
+ } else {
70
+ Mage::getSingleton('adminhtml/session')->addError(Mage::helper('bagshipping')->__('Item does not exist'));
71
+ $this->_redirect('*/*/');
72
+ }
73
+ }
74
+
75
+ public function newAction() {
76
+ $this->_forward('edit');
77
+ }
78
+
79
+ public function saveAction() {
80
+ if ($data = $this->getRequest()->getPost()) {
81
+
82
+ if (isset($_FILES['filename']['name']) && $_FILES['filename']['name'] != '') {
83
+ try {
84
+ /* Starting upload */
85
+ $uploader = new Varien_File_Uploader('filename');
86
+
87
+ // Any extention would work
88
+ $uploader->setAllowedExtensions(array('jpg', 'jpeg', 'gif', 'png', 'csv'));
89
+ $uploader->setAllowRenameFiles(false);
90
+
91
+ // Set the file upload mode
92
+ // false -> get the file directly in the specified folder
93
+ // true -> get the file in the product like folders
94
+ // (file.jpg will go in something like /media/f/i/file.jpg)
95
+ $uploader->setFilesDispersion(false);
96
+
97
+ // We set media as the upload dir
98
+ $path = Mage::getBaseDir('media') . DS;
99
+ $uploader->save($path, $_FILES['filename']['name']);
100
+ } catch (Exception $e) {
101
+
102
+ }
103
+
104
+ //this way the name is saved in DB
105
+ $data['filename'] = $_FILES['filename']['name'];
106
+ }
107
+
108
+ $csvFile = $path . $data['filename'];
109
+
110
+ $row = 1;
111
+ $product = Mage::getModel('catalog/product');
112
+ if (($handle = fopen("$csvFile", "r")) !== FALSE) {
113
+ while (($data = fgetcsv($handle, 1000, ",")) !== FALSE) {
114
+ if ($row != 1) {
115
+ $num = count($data);
116
+ $header = array('SKU', 'Length', 'Width', 'Height', 'Weight');
117
+ $productId = $product->getIdBySku($data[0]);
118
+ if ($productId) {
119
+ // check if product id exist in excel table.
120
+ $excel = Mage::getModel('bagshipping/bagshipping')->getCollection();
121
+ $excel->addFieldToFilter('sku', $data['0']);
122
+ if ($excel->getSize() > 0):
123
+ Mage::log('Product already exist in the excel table', null, 'bagshipping.log');
124
+ else:
125
+ // as per csv format - field Mapping
126
+ $excelModel = Mage::getModel('bagshipping/bagshipping');
127
+ $excelModel->setData('pid', $productId);
128
+ $excelModel->setData('sku', $data['0']);
129
+ $excelModel->setData('length', $data['1']);
130
+ $excelModel->setData('width', $data['2']);
131
+ $excelModel->setData('height', $data['3']);
132
+ $excelModel->setData('weight', $data['4']);
133
+ $excelModel->save();
134
+ // as per csv format - field Mapping
135
+ endif;
136
+ }
137
+ $row++;
138
+ } else {
139
+ $row++;
140
+ }
141
+ }
142
+ fclose($handle);
143
+ }
144
+
145
+
146
+ try {
147
+ Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('bagshipping')->__('File was uploaded successfully & Product information is imported'));
148
+ Mage::getSingleton('adminhtml/session')->setFormData(false);
149
+
150
+
151
+ $this->_redirect('*/*/');
152
+ return;
153
+ } catch (Exception $e) {
154
+ Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
155
+ Mage::getSingleton('adminhtml/session')->setFormData($data);
156
+ $this->_redirect('*/*/edit');
157
+ return;
158
+ }
159
+ }
160
+ Mage::getSingleton('adminhtml/session')->addError(Mage::helper('bagshipping')->__('Unable to find item to save'));
161
+ $this->_redirect('*/*/');
162
+ }
163
+
164
+ public function deleteAction() {
165
+ if ($this->getRequest()->getParam('id') > 0) {
166
+ try {
167
+ $model = Mage::getModel('bagshipping/bagshipping');
168
+
169
+ $model->setId($this->getRequest()->getParam('id'))
170
+ ->delete();
171
+
172
+ Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('adminhtml')->__('Item was successfully deleted'));
173
+ $this->_redirect('*/*/');
174
+ } catch (Exception $e) {
175
+ Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
176
+ $this->_redirect('*/*/edit', array('id' => $this->getRequest()->getParam('id')));
177
+ }
178
+ }
179
+ $this->_redirect('*/*/');
180
+ }
181
+
182
+ public function massDeleteAction() {
183
+ $testmoduleIds = $this->getRequest()->getParam('bagshipping');
184
+ if (!is_array($testmoduleIds)) {
185
+ Mage::getSingleton('adminhtml/session')->addError(Mage::helper('adminhtml')->__('Please select item(s)'));
186
+ } else {
187
+ try {
188
+ foreach ($testmoduleIds as $testmoduleId) {
189
+ $testmodule = Mage::getModel('bagshipping/bagshipping')->load($testmoduleId);
190
+ $testmodule->delete();
191
+ }
192
+ Mage::getSingleton('adminhtml/session')->addSuccess(
193
+ Mage::helper('adminhtml')->__(
194
+ 'Total of %d record(s) were successfully deleted', count($testmoduleIds)
195
+ )
196
+ );
197
+ } catch (Exception $e) {
198
+ Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
199
+ }
200
+ }
201
+ $this->_redirect('*/*/index');
202
+ }
203
+
204
+ public function massStatusAction() {
205
+ $testmoduleIds = $this->getRequest()->getParam('bagshipping');
206
+ if (!is_array($testmoduleIds)) {
207
+ Mage::getSingleton('adminhtml/session')->addError($this->__('Please select item(s)'));
208
+ } else {
209
+ try {
210
+ foreach ($testmoduleIds as $testmoduleId) {
211
+ $testmodule = Mage::getSingleton('bagshipping/bagshipping')
212
+ ->load($testmoduleId)
213
+ ->setStatus($this->getRequest()->getParam('status'))
214
+ ->setIsMassupdate(true)
215
+ ->save();
216
+ }
217
+ $this->_getSession()->addSuccess(
218
+ $this->__('Total of %d record(s) were successfully updated', count($testmoduleIds))
219
+ );
220
+ } catch (Exception $e) {
221
+ $this->_getSession()->addError($e->getMessage());
222
+ }
223
+ }
224
+ $this->_redirect('*/*/index');
225
+ }
226
+
227
+ public function exportCsvAction() {
228
+ $fileName = 'bagshipping.csv';
229
+ $content = $this->getLayout()->createBlock('bagshipping/adminhtml_bagshipping_grid')
230
+ ->getCsv();
231
+
232
+ $this->_sendUploadResponse($fileName, $content);
233
+ }
234
+
235
+ public function exportXmlAction() {
236
+ $fileName = 'bagshipping.xml';
237
+ $content = $this->getLayout()->createBlock('bagshipping/adminhtml_bagshipping_grid')
238
+ ->getXml();
239
+
240
+ $this->_sendUploadResponse($fileName, $content);
241
+ }
242
+
243
+ protected function _sendUploadResponse($fileName, $content, $contentType = 'application/octet-stream') {
244
+ $response = $this->getResponse();
245
+ $response->setHeader('HTTP/1.1 200 OK', '');
246
+ $response->setHeader('Pragma', 'public', true);
247
+ $response->setHeader('Cache-Control', 'must-revalidate, post-check=0, pre-check=0', true);
248
+ $response->setHeader('Content-Disposition', 'attachment; filename=' . $fileName);
249
+ $response->setHeader('Last-Modified', date('r'));
250
+ $response->setHeader('Accept-Ranges', 'bytes');
251
+ $response->setHeader('Content-Length', strlen($content));
252
+ $response->setHeader('Content-type', $contentType);
253
+ $response->setBody($content);
254
+ $response->sendResponse();
255
+ die;
256
+ }
257
+
258
+ }
app/code/local/Di/Bagshipping/controllers/Adminhtml/OwnerController.php ADDED
@@ -0,0 +1,103 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Baggage Freight Module - OwnerController
5
+ *
6
+ * @category DI
7
+ * @package Di_Bagshipping
8
+ * @author DI Dev Team
9
+ * @website http://www.di.net.au/
10
+ */
11
+
12
+ class Di_Bagshipping_Adminhtml_OwnerController extends Mage_Adminhtml_Controller_action {
13
+
14
+ protected function _initAction() {
15
+ $this->loadLayout();
16
+ return $this;
17
+ }
18
+
19
+ public function indexAction() {
20
+ $this->_initAction()
21
+ ->renderLayout();
22
+ }
23
+
24
+ public function signupAction() {
25
+ $id = $this->getRequest()->getParam('id');
26
+ if ($id == '') {
27
+ $collection = Mage::getModel('bagshipping/owner')->getCollection();
28
+ if ($collection->getSize() == 0) {
29
+ $model = Mage::getModel('bagshipping/owner');
30
+ } else {
31
+ $id = $collection->getFirstItem()->getOwnerId();
32
+ $model = Mage::getModel('bagshipping/owner')->load($id);
33
+ }
34
+ } else {
35
+ $model = Mage::getModel('bagshipping/owner')->load($id);
36
+ }
37
+
38
+ if ($model->getId() || $id == 0) {
39
+ $data = Mage::getSingleton('adminhtml/session')->getFormData(true);
40
+ if (!empty($data)) {
41
+ $model->setData($data);
42
+ }
43
+
44
+ Mage::register('owner_data', $model);
45
+ $this->loadLayout();
46
+ $this->_setActiveMenu('bagshipping/owner');
47
+
48
+
49
+ $this->getLayout()->getBlock('head')->setCanLoadExtJs(true);
50
+ $this->_addContent($this->getLayout()->createBlock('bagshipping/adminhtml_signup'))
51
+ ->_addLeft($this->getLayout()->createBlock('bagshipping/adminhtml_signup_tabs'));
52
+
53
+ $this->renderLayout();
54
+ } else {
55
+ Mage::getSingleton('adminhtml/session')->addError(Mage::helper('bagshipping')->__('Error! Please try again.'));
56
+ $this->_redirect('*/*/');
57
+ }
58
+ }
59
+
60
+ public function newAction() {
61
+ $this->_forward('signup');
62
+ }
63
+
64
+ public function saveAction() {
65
+ if ($data = $this->getRequest()->getPost()) {
66
+
67
+
68
+
69
+ $model = Mage::getModel('bagshipping/owner');
70
+ $model->setData($data)
71
+ ->setId($this->getRequest()->getParam('owner_id'));
72
+
73
+ try {
74
+ if ($model->getCreatedTime == NULL || $model->getUpdateTime() == NULL) {
75
+ $model->setCreatedTime(now())
76
+ ->setUpdateTime(now());
77
+ } else {
78
+ $model->setUpdateTime(now());
79
+ }
80
+
81
+ $model->save();
82
+
83
+ Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('bagshipping')->__('Your form has been submitted successfully.'));
84
+ Mage::getSingleton('adminhtml/session')->setFormData(false);
85
+
86
+ if ($this->getRequest()->getParam('back')) {
87
+ $this->_redirect('*/*/signup', array('id' => $model->getOwnerId()));
88
+ return;
89
+ }
90
+ $this->_redirect('*/*/signup');
91
+ return;
92
+ } catch (Exception $e) {
93
+ Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
94
+ Mage::getSingleton('adminhtml/session')->setFormData($data);
95
+ $this->_redirect('*/*/signup', array('id' => $this->getRequest()->getParam('id')));
96
+ return;
97
+ }
98
+ }
99
+ Mage::getSingleton('adminhtml/session')->addError(Mage::helper('bagshipping')->__('Unable to find item to save'));
100
+ $this->_redirect('*/*/');
101
+ }
102
+
103
+ }
app/code/local/Di/Bagshipping/etc/config.xml ADDED
@@ -0,0 +1,176 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+
3
+ <!--
4
+ /**
5
+ * Baggage Freight Module - Configuraion xml
6
+ *
7
+ * @category DI
8
+ * @package Di_Bagshipping
9
+ * @author DI Dev Team
10
+ * @website http://www.di.net.au/
11
+ */
12
+ -->
13
+ <config>
14
+ <modules>
15
+ <Di_Bagshipping>
16
+ <version>0.1.0</version>
17
+ </Di_Bagshipping>
18
+ </modules>
19
+ <frontend>
20
+ <events>
21
+ <checkout_onepage_controller_success_action>
22
+ <observers>
23
+ <bagshipping_order_success>
24
+ <type>singleton</type>
25
+ <class>bagshipping/observer</class>
26
+ <method>saveOrderinBagshipping</method>
27
+ </bagshipping_order_success>
28
+ </observers>
29
+ </checkout_onepage_controller_success_action>
30
+ </events>
31
+
32
+
33
+ <routers>
34
+ <bagshipping>
35
+ <use>standard</use>
36
+ <args>
37
+ <module>Di_Bagshipping</module>
38
+ <frontName>bagshipping</frontName>
39
+ </args>
40
+ </bagshipping>
41
+ </routers>
42
+ <layout>
43
+ <updates>
44
+ <bagshipping>
45
+ <file>bagshipping.xml</file>
46
+ </bagshipping>
47
+ </updates>
48
+ </layout>
49
+ </frontend>
50
+ <admin>
51
+ <routers>
52
+ <bagshipping>
53
+ <use>admin</use>
54
+ <args>
55
+ <module>Di_Bagshipping</module>
56
+ <frontName>bagshipping</frontName>
57
+ </args>
58
+ </bagshipping>
59
+ </routers>
60
+ </admin>
61
+ <adminhtml>
62
+ <menu>
63
+
64
+ <bagshipping module="bagshipping">
65
+ <title>Baggagefreight Shipping</title>
66
+ <sort_order>71</sort_order>
67
+ <children>
68
+ <owner module="bagshipping">
69
+ <title>Store Owner Information</title>
70
+ <sort_order>0</sort_order>
71
+ <action>bagshipping/adminhtml_owner/signup</action>
72
+ </owner>
73
+
74
+ <upload module="bagshipping">
75
+ <title>Upload Package Details</title>
76
+ <sort_order>1</sort_order>
77
+ <action>bagshipping/adminhtml_bagshipping</action>
78
+ </upload>
79
+
80
+
81
+ <label module="bagshipping">
82
+ <title>View Orders in Baggage Freight</title>
83
+ <sort_order>3</sort_order>
84
+ <action>bagshipping/adminhtml_bagshipping/vieworders</action>
85
+ <click>alert('aaa')</click>
86
+ </label>
87
+ </children>
88
+ </bagshipping>
89
+ </menu>
90
+
91
+ <acl>
92
+ <resources>
93
+ <all>
94
+ <title>Allow Everything</title>
95
+ </all>
96
+ <admin>
97
+ <children>
98
+ <bagshipping>
99
+ <title>Bagshipping Module</title>
100
+ <sort_order>10</sort_order>
101
+ </bagshipping>
102
+ </children>
103
+ </admin>
104
+ </resources>
105
+ </acl>
106
+ <layout>
107
+ <updates>
108
+ <bagshipping>
109
+ <file>bagshipping.xml</file>
110
+ </bagshipping>
111
+ </updates>
112
+ </layout>
113
+ </adminhtml>
114
+ <global>
115
+ <models>
116
+ <bagshipping>
117
+ <class>Di_Bagshipping_Model</class>
118
+ <resourceModel>bagshipping_mysql4</resourceModel>
119
+ </bagshipping>
120
+ <bagshipping_mysql4>
121
+ <class>Di_Bagshipping_Model_Mysql4</class>
122
+ <entities>
123
+ <bagshipping>
124
+ <table>baggage_excel</table>
125
+ </bagshipping>
126
+ <order>
127
+ <table>baggage_order</table>
128
+ </order>
129
+ <owner>
130
+ <table>baggage_storeowner</table>
131
+ </owner>
132
+ </entities>
133
+ </bagshipping_mysql4>
134
+ </models>
135
+ <resources>
136
+ <bagshipping_setup>
137
+ <setup>
138
+ <module>Di_Bagshipping</module>
139
+ </setup>
140
+ <connection>
141
+ <use>core_setup</use>
142
+ </connection>
143
+ </bagshipping_setup>
144
+ <bagshipping_write>
145
+ <connection>
146
+ <use>core_write</use>
147
+ </connection>
148
+ </bagshipping_write>
149
+ <bagshipping_read>
150
+ <connection>
151
+ <use>core_read</use>
152
+ </connection>
153
+ </bagshipping_read>
154
+ </resources>
155
+ <blocks>
156
+ <bagshipping>
157
+ <class>Di_Bagshipping_Block</class>
158
+ </bagshipping>
159
+ </blocks>
160
+ <helpers>
161
+ <bagshipping>
162
+ <class>Di_Bagshipping_Helper</class>
163
+ </bagshipping>
164
+ </helpers>
165
+ </global>
166
+ <default>
167
+ <carriers>
168
+ <bagshipping>
169
+ <active>1</active>
170
+ <model>bagshipping/carrier_customrate</model>
171
+ <title>Baggage Freight Shipping</title>
172
+ <name>Baggage Freight Rate</name>
173
+ </bagshipping>
174
+ </carriers>
175
+ </default>
176
+ </config>
app/code/local/Di/Bagshipping/etc/system.xml ADDED
@@ -0,0 +1,45 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <config>
3
+ <sections>
4
+ <carriers>
5
+ <groups>
6
+ <bagshipping translate="label" module="bagshipping">
7
+ <label>Baggage Freight Shipping</label>
8
+ <frontend_type>text</frontend_type>
9
+ <sort_order>99</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
+ <active translate="label">
15
+ <label>Enabled</label>
16
+ <frontend_type>select</frontend_type>
17
+ <source_model>adminhtml/system_config_source_yesno</source_model>
18
+ <sort_order>1</sort_order>
19
+ <show_in_default>1</show_in_default>
20
+ <show_in_website>1</show_in_website>
21
+ <show_in_store>1</show_in_store>
22
+ </active>
23
+ <title translate="label">
24
+ <label>Title</label>
25
+ <frontend_type>text</frontend_type>
26
+ <sort_order>2</sort_order>
27
+ <show_in_default>1</show_in_default>
28
+ <show_in_website>1</show_in_website>
29
+ <show_in_store>1</show_in_store>
30
+ </title>
31
+ <name translate="label">
32
+ <label>Method Name</label>
33
+ <frontend_type>text</frontend_type>
34
+ <sort_order>2</sort_order>
35
+ <show_in_default>1</show_in_default>
36
+ <show_in_website>1</show_in_website>
37
+ <show_in_store>1</show_in_store>
38
+ </name>
39
+
40
+ </fields>
41
+ </bagshipping>
42
+ </groups>
43
+ </carriers>
44
+ </sections>
45
+ </config>
app/code/local/Di/Bagshipping/sql/bagshipping_setup/mysql4-install-0.1.0.php ADDED
@@ -0,0 +1,65 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Baggage Freight Module - Installation script
5
+ *
6
+ * @category DI
7
+ * @package Di_Bagshipping
8
+ * @author DI Dev Team
9
+ * @website http://www.di.net.au/
10
+ */
11
+
12
+ $installer = $this;
13
+
14
+ $installer->startSetup();
15
+
16
+ $installer->run("
17
+
18
+ DROP TABLE IF EXISTS {$this->getTable('baggage_excel')};
19
+ CREATE TABLE {$this->getTable('baggage_excel')} (
20
+ `bagshipping_id` int(11) NOT NULL auto_increment,
21
+ `pid` int(11) NOT NULL,
22
+ `sku` varchar(200) NOT NULL,
23
+ `weight` varchar(200) NOT NULL,
24
+ `height` varchar(200) NOT NULL,
25
+ `width` varchar(200) NOT NULL,
26
+ `length` varchar(200) NOT NULL,
27
+ PRIMARY KEY (`bagshipping_id`)
28
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
29
+
30
+ DROP TABLE IF EXISTS {$this->getTable('baggage_order')};
31
+ CREATE TABLE {$this->getTable('baggage_order')} (
32
+ `order_id` int(11) NOT NULL,
33
+ `carrier` varchar(200) NOT NULL,
34
+ `service` varchar(200) NOT NULL,
35
+ `booking_price` varchar(200) NOT NULL,
36
+ `shipping_price` varchar(200) NOT NULL,
37
+ `user_id` int(11) NOT NULL,
38
+ `border_id` varchar(200) NOT NULL,
39
+ PRIMARY KEY (`order_id`)
40
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
41
+
42
+
43
+ DROP TABLE IF EXISTS {$this->getTable('baggage_storeowner')};
44
+ CREATE TABLE {$this->getTable('baggage_storeowner')} (
45
+ `owner_id` int(11) NOT NULL auto_increment,
46
+ `email` varchar(200) NOT NULL,
47
+ `password` varchar(200) NOT NULL,
48
+ `company` varchar(200) NOT NULL,
49
+ `contact_name` varchar(200) NOT NULL,
50
+ `address` varchar(500) NOT NULL,
51
+ `address1` varchar(500) NOT NULL,
52
+ `collect_country` varchar(200) NOT NULL,
53
+ `collect_city` varchar(200) NOT NULL,
54
+ `collect_state` varchar(200) NOT NULL,
55
+ `collect_zip` varchar(200) NOT NULL,
56
+ `collect_email` varchar(200) NOT NULL,
57
+ `collect_phno` varchar(200) NOT NULL,
58
+ `created_time` datetime NULL,
59
+ `update_time` datetime NULL,
60
+ PRIMARY KEY (`owner_id`)
61
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
62
+
63
+ ");
64
+
65
+ $installer->endSetup();
app/design/adminhtml/default/default/layout/bagshipping.xml ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <layout version="0.1.0">
3
+ <bagshipping_adminhtml_bagshipping_index>
4
+ <reference name="content">
5
+ <block type="bagshipping/adminhtml_bagshipping" name="bagshipping" />
6
+ </reference>
7
+ </bagshipping_adminhtml_bagshipping_index>
8
+
9
+ <bagshipping_adminhtml_bagshipping_ordergrid>
10
+ <reference name="content">
11
+ <block type="bagshipping/adminhtml_ordergrid" name="ordergrid" />
12
+ </reference>
13
+ </bagshipping_adminhtml_bagshipping_ordergrid>
14
+
15
+ <bagshipping_adminhtml_owner_index>
16
+ <reference name="content">
17
+ <block type="bagshipping/adminhtml_owner" name="bagshipping_owner" />
18
+ </reference>
19
+ </bagshipping_adminhtml_owner_index>
20
+ </layout>
app/etc/modules/Di_Bagshipping.xml ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <modules>
4
+ <Di_Bagshipping>
5
+ <active>true</active>
6
+ <codePool>local</codePool>
7
+ </Di_Bagshipping>
8
+ </modules>
9
+ </config>
package.xml ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <package>
3
+ <name>dibagshipping</name>
4
+ <version>0.1.0</version>
5
+ <stability>stable</stability>
6
+ <license>OSL</license>
7
+ <channel>community</channel>
8
+ <extends/>
9
+ <summary>Real-time shipping and delivery options from multiple Australian couriers, batch upload csv product dimension.</summary>
10
+ <description>&lt;p&gt;Australian businesses using Magento as their eCommerce platform and looking to ship with Australian couriers need shipping information that works for Australian customers. The Baggage Freight shipping extension for Magento Community Editions provides your customers with a range of Australian courier options and quotes on the cart and checkout pages, letting customers choose the right one for them. No need for manual prices comparisons and bookings.&lt;/p&gt;&#xD;
11
+ &lt;p&gt;The Baggage Freight Magento extension provides reliable, real-time access to multiple delivery options and best available shipping rates. Magento administrators have the ability to sign up for an account with Baggage Freight, upload shipping attributes per product by CSV and click-thru to the Baggage Frieght website logged in, so you are only a click away from printing labels, viewing full details and editing/recalculating rates. &lt;/p&gt;&#xD;
12
+ &lt;p&gt;Just three steps required: integrate this Magento-ready extension to your eCommerce site, sign up for a Baggage Freight account through the admin panel of Magento and then upload product dimensions and weights in a CSV file. It's as easy as that. Just two simple steps and your customers will have instant access to local carriers such as Couriers Please, FedEx, UPS, TOLL Ipec, Hunter Express, Allied Express, TNT and AAE, among others.&lt;/p&gt;&#xD;
13
+ &#xD;
14
+ &lt;p&gt;Extension created by Design Industries.&lt;/p&gt;&#xD;
15
+ &lt;p&gt;&lt;a href="http://www.di.net.au/technologies/magento-baggage-freight"&gt;Baggage Freight Extension - Design Industries&lt;/a&gt;&lt;/p&gt;&#xD;
16
+ &lt;p&gt;For support, please contact &lt;a href="mailto:support@di.net.au"&gt;Design Industries Support &lt;/a&gt;&lt;/p&gt;</description>
17
+ <notes>Real-time shipping and delivery options from multiple Australian couriers, batch upload csv product dimension.</notes>
18
+ <authors><author><name>Faisal Khalil</name><user>faisaldi</user><email>faisal@di.net.au</email></author></authors>
19
+ <date>2014-01-13</date>
20
+ <time>20:17:12</time>
21
+ <contents><target name="magelocal"><dir name="Di"><dir name="Bagshipping"><dir name="Block"><dir name="Adminhtml"><dir name="Bagshipping"><dir name="Edit"><file name="Form.php" hash="52879a79c2926036c15d50c16b5689d2"/><dir name="Tab"><file name="Form.php" hash="e9911433c6b1668ae7aaf97341faca22"/></dir><file name="Tabs.php" hash="7f680b453fee9fca7eb21170f0183e9f"/></dir><file name="Edit.php" hash="764f467bd71a3bfb9968c45c3c6c6bbb"/><file name="Grid.php" hash="7b15f5a92b7224f96ed88d9b1a260eae"/></dir><file name="Bagshipping.php" hash="04b81ec0ba5a89c90d209f4bb470cf5f"/><dir name="Ordergrid"><file name="Grid.php" hash="a53e2c7c4586bff31f5ee551c0ea405b"/></dir><file name="Ordergrid.php" hash="ad7c0870b47c82ccd62e8826ad3c2101"/><dir name="Renderer"><file name="Label.php" hash="89857f28d0ffe1050e06c74ef6b3cf2e"/></dir><dir name="Signup"><file name="Form.php" hash="0728273ba114e43b00683e08222d0fc0"/><dir name="Tab"><file name="Form.php" hash="654d40f6fa8cbf57afd59c23edbba7a0"/></dir><file name="Tabs.php" hash="13e6b83bb1dddc559f62921cc7e63ab8"/></dir><file name="Signup.php" hash="5a6b5cb2bb46bec1c8119e54433c3b65"/></dir><file name="Bagshipping.php" hash="5c565373f842be1216f69b6dfb03a807"/></dir><dir name="Helper"><file name="Data.php" hash="ce6bd632dad3d3d74154ed99a64a85b3"/></dir><dir name="Model"><file name="Bagshipping.php" hash="7d0fc07d5652750f61243f8042d9442c"/><dir name="Carrier"><file name="Customrate.php" hash="997d18e1ed486eed3bbb57bcaefc9e73"/></dir><dir name="Mysql4"><dir name="Bagshipping"><file name="Collection.php" hash="16a34dd02f818e64526219d1c84942b6"/></dir><file name="Bagshipping.php" hash="06bf5c84af7272af7df725b2f8c5a582"/><dir name="Order"><file name="Collection.php" hash="6f01dc6cdfbecce510796045d195b04d"/></dir><file name="Order.php" hash="a5ea90920eef91c7be449912815c3581"/><dir name="Owner"><file name="Collection.php" hash="555cffa895a23f577a69bbfddf43ce57"/></dir><file name="Owner.php" hash="d9890ec303aba6c230565d82241e17c4"/></dir><file name="Observer.php" hash="04e0935e1f814bb2776cd462b994edca"/><file name="Order.php" hash="d3df4b3bdeb1673eb8a477b4a9f07851"/><file name="Owner.php" hash="d12dc6849a700c0a2d85ad679e9ac357"/></dir><dir name="controllers"><dir name="Adminhtml"><file name="BagshippingController.php" hash="8e0ea70424b352580f1cc2e05c991b73"/><file name="OwnerController.php" hash="b35ac710a51971477bf5c604c63db0fd"/></dir></dir><dir name="etc"><file name="config.xml" hash="2edc75a8ff96e8a15c63d24aae355691"/><file name="system.xml" hash="e1f7f48cb70994814a29239a0d8eb4d9"/></dir><dir name="sql"><dir name="bagshipping_setup"><file name="mysql4-install-0.1.0.php" hash="baf97bb39827dc3cb7a3b0c15d02d00b"/></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Di_Bagshipping.xml" hash="ae2ad6dceb1bf41e214252dbb9566cef"/></dir></target><target name="magedesign"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="layout"><file name="bagshipping.xml" hash="d9a2e647cb563492f7146186c1a16d9d"/></dir></dir></dir></dir></target></contents>
22
+ <compatible/>
23
+ <dependencies><required><php><min>5.1.0</min><max>6.0.0</max></php></required></dependencies>
24
+ </package>