logicbroker - Version 1.0.2

Version Notes

Stable

Download this release

Release Info

Developer Logicbroker
Extension logicbroker
Version 1.0.2
Comparing to
See all releases


Code changes from version 1.0.1 to 1.0.2

Files changed (28) hide show
  1. app/code/community/Logicbroker/Fulfillment/sql/logicbroker_setup/mysql4-install-1.0.0.php +1 -0
  2. app/locale/en_US/template/email/logicbroker.html +0 -17
  3. includes/src/Logicbroker/Fulfillment/controllers/Adminhtml/LogicbrokerController.php +193 -0
  4. includes/src/Logicbroker_Fulfillment_Block_Adminhtml_Logicbroker.php +19 -0
  5. includes/src/Logicbroker_Fulfillment_Block_Adminhtml_Logicbroker_Edit.php +100 -0
  6. includes/src/Logicbroker_Fulfillment_Block_Adminhtml_Logicbroker_Edit_Form.php +26 -0
  7. includes/src/Logicbroker_Fulfillment_Block_Adminhtml_Logicbroker_Edit_Tab_Form.php +176 -0
  8. includes/src/Logicbroker_Fulfillment_Block_Adminhtml_Logicbroker_Edit_Tabs.php +32 -0
  9. includes/src/Logicbroker_Fulfillment_Block_Adminhtml_Logicbroker_Grid.php +129 -0
  10. includes/src/Logicbroker_Fulfillment_Block_Adminhtml_System_Config_Fieldset_Hint.php +134 -0
  11. includes/src/Logicbroker_Fulfillment_Block_Adminhtml_System_Config_Submitbutton.php +100 -0
  12. includes/src/Logicbroker_Fulfillment_Block_Adminhtml_Widget_Grid_Column_Renderer_Textaction.php +37 -0
  13. includes/src/Logicbroker_Fulfillment_Helper_Data.php +17 -0
  14. includes/src/Logicbroker_Fulfillment_Model_Abstract.php +21 -0
  15. includes/src/Logicbroker_Fulfillment_Model_Apicreate.php +14 -0
  16. includes/src/Logicbroker_Fulfillment_Model_Email.php +71 -0
  17. includes/src/Logicbroker_Fulfillment_Model_Excelxml.php +202 -0
  18. includes/src/Logicbroker_Fulfillment_Model_Infromlogicbroker.php +15 -0
  19. includes/src/Logicbroker_Fulfillment_Model_Logicbroker.php +367 -0
  20. includes/src/Logicbroker_Fulfillment_Model_Observer.php +47 -0
  21. includes/src/Logicbroker_Fulfillment_Model_Resource_Supplier.php +16 -0
  22. includes/src/Logicbroker_Fulfillment_Model_Resource_Supplier_Collection.php +20 -0
  23. includes/src/Logicbroker_Fulfillment_Model_Supplier.php +126 -0
  24. includes/src/Logicbroker_Fulfillment_Model_Synchronize.php +45 -0
  25. includes/src/Logicbroker_Fulfillment_Model_System_Config_Source_Attributecodes.php +31 -0
  26. includes/src/Logicbroker_Fulfillment_Model_System_Config_Source_Ediqualifier.php +70 -0
  27. includes/src/Logicbroker_Fulfillment_Model_System_Config_Source_Optionvalues.php +66 -0
  28. package.xml +5 -5
app/code/community/Logicbroker/Fulfillment/sql/logicbroker_setup/mysql4-install-1.0.0.php CHANGED
@@ -47,6 +47,7 @@ CREATE TABLE {$this->getTable('logicbroker_vendor')}(vendor_id int not null auto
47
  SQLTEXT;
48
 
49
  $installer->run($sql);
 
50
  //demo
51
  //Mage::getModel('core/url_rewrite')->setId(null);
52
  //demo
47
  SQLTEXT;
48
 
49
  $installer->run($sql);
50
+ //Mage::getModel('compiler/process')->registerIncludePath(false);
51
  //demo
52
  //Mage::getModel('core/url_rewrite')->setId(null);
53
  //demo
app/locale/en_US/template/email/logicbroker.html DELETED
@@ -1,17 +0,0 @@
1
- <!--@subject Contact Form@-->
2
- <!--@vars
3
- {"var data.name":"Sender Name",
4
- "var data.email":"Sender Email",
5
- "var data.telephone":"Sender Telephone",
6
- "var data.comment":"Comment"}
7
- @-->
8
-
9
- {{if templatevar.isnewreg}}
10
- A new user has installed Extension on following URL -: {{store url=""}}
11
- {{else}}
12
- Please find the excel sheet in attachment customer details are given below -:<br> Name : {{var templatevar.firstname}} <span>{{var templatevar.lastname}}
13
- </span> <br> Email : {{var templatevar.email}}
14
- {{/if}}
15
-
16
-
17
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
includes/src/Logicbroker/Fulfillment/controllers/Adminhtml/LogicbrokerController.php ADDED
@@ -0,0 +1,193 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Logicbroker
5
+ *
6
+ * @category Community
7
+ * @package Logicbroker_Fulfillment
8
+ */
9
+
10
+ class Logicbroker_Fulfillment_Adminhtml_LogicbrokerController extends Mage_Adminhtml_Controller_Action
11
+ {
12
+
13
+ protected function _initAction() {
14
+ $this->loadLayout()
15
+ ->_setActiveMenu('logicbroker/suppliers')
16
+ ->_addBreadcrumb(Mage::helper('adminhtml')->__('Vendor Manager'), Mage::helper('adminhtml')->__('Vendor Manager'));
17
+
18
+ return $this;
19
+ }
20
+
21
+ public function indexAction() {
22
+ $this->_initAction()
23
+ ->renderLayout();
24
+ }
25
+
26
+ /**
27
+ * suppplier grid for AJAX request
28
+ */
29
+ public function gridAction() {
30
+ $this->getResponse()->setBody(
31
+ $this->getLayout()->createBlock('logicbroker/adminhtml_logicbroker_grid')->toHtml()
32
+ );
33
+ }
34
+ public function editAction() {
35
+ $id = $this->getRequest()->getParam('vendor_id');
36
+ $model = Mage::getModel('logicbroker/supplier')->load($id);
37
+
38
+ if ($model->getVendorId() || $id == 0) {
39
+ $data = Mage::getSingleton('adminhtml/session')->getFormData(true);
40
+ if (!empty($data)) {
41
+ $model->setData($data);
42
+
43
+ }
44
+ Mage::register('logicbroker_data', $model);
45
+
46
+ $this->loadLayout();
47
+ $this->_setActiveMenu('logicbroker/suppliers');
48
+
49
+ $this->_addBreadcrumb(Mage::helper('adminhtml')->__('Vendor Manager'), Mage::helper('adminhtml')->__('Vendor Manager'));
50
+ $this->getLayout()->getBlock('head')->setCanLoadExtJs(true);
51
+
52
+ $this->_addContent($this->getLayout()->createBlock('logicbroker/adminhtml_logicbroker_edit'))
53
+ ->_addLeft($this->getLayout()->createBlock('logicbroker/adminhtml_logicbroker_edit_tabs'));
54
+
55
+ $this->renderLayout();
56
+ } else {
57
+ Mage::getSingleton('adminhtml/session')->addError(Mage::helper('logicbroker')->__('Vendor does not exist'));
58
+ $this->_redirect('*/*/');
59
+ }
60
+ }
61
+
62
+ public function newAction()
63
+ {
64
+ $this->loadLayout();
65
+ $this->_setActiveMenu('logicbroker/suppliers');
66
+ $this->_addContent($this->getLayout()->createBlock('logicbroker/adminhtml_logicbroker_edit'))
67
+ ->_addLeft($this->getLayout()->createBlock('logicbroker/adminhtml_logicbroker_edit_tabs'));
68
+ $this->renderLayout();
69
+
70
+ }
71
+
72
+ public function saveAction() {
73
+ if ($data = $this->getRequest()->getPost()) {
74
+
75
+
76
+ $model = Mage::getModel('logicbroker/supplier');
77
+ if ($id = $this->getRequest()->getParam('vendor_id')) {//the parameter name may be different
78
+ $model->load($id);
79
+ }
80
+
81
+
82
+ $model->addData($data);
83
+ $companyid = $this->getRequest()->getParam('company_id');
84
+
85
+ try {
86
+ if(!empty($data['addnewoption'])){
87
+ $model->setData('magento_vendor_code',strtolower($data['addnewoption']));
88
+ }
89
+ //validate compny id as unique
90
+ $validate = $model->validateCompany($companyid,$this->getRequest()
91
+ ->getParam('vendor_id'));
92
+ if($validate == 1){
93
+ Mage::getSingleton('adminhtml/session')->addError(Mage::helper('logicbroker')->__('Duplicate Company ID'));
94
+ $this->_redirect('*/*/edit', array('vendor_id' => $model->getVendorId()));
95
+ return;
96
+ }
97
+ //$model->getFtpPassword = md5($model->getFtpPassword());
98
+ //$model->setData('ftp_password',$model->getFtpPassword);
99
+ $model->save();
100
+ if(!empty($data['addnewoption'])){
101
+ Mage::getModel('logicbroker/logicbroker')->createOptionValueOnSave($model->getMagentoVendorCode());
102
+ }
103
+
104
+ Mage::getSingleton('adminhtml/session')->setFormData(false);
105
+ Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('logicbroker')->__('vendor was successfully saved'));
106
+
107
+ if ($this->getRequest()->getParam('back')) {
108
+ $this->_redirect('*/*/edit', array('vendor_id' => $model->getVendorId()));
109
+ return;
110
+ }
111
+ $this->_redirect('*/*/');
112
+ return;
113
+ } catch (Exception $e) {
114
+ Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
115
+ Mage::getSingleton('adminhtml/session')->setFormData($data);
116
+ $this->_redirect('*/*/edit', array('vendor_id'=>$model->getVendorId(), '_current'=>true));
117
+ return;
118
+ }
119
+ }
120
+ Mage::getSingleton('adminhtml/session')->addError(Mage::helper('logicbroker')->__('Unable to find vendor to save'));
121
+ $this->_redirect('*/*/');
122
+ }
123
+
124
+ public function deleteAction()
125
+ {
126
+ // check if we know what should be deleted
127
+ if ($id = $this->getRequest()->getParam('vendor_id')) {
128
+ try {
129
+ // init model and delete
130
+ $model = Mage::getModel('logicbroker/supplier');
131
+ $model->load($id);
132
+ //$model->deleteOption($model->getMagentoVendorAttributeId(),$model->getMagentoSupplierAttribute());
133
+ $model->setData('status','deleted');
134
+ $model->save();
135
+ //$model->delete();
136
+ // display success message
137
+ Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('logicbroker')->__('The vendor has been deleted.'));
138
+ // go to grid
139
+ $this->_redirect('*/*/');
140
+ return;
141
+
142
+ } catch (Exception $e) {
143
+ // display error message
144
+ Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
145
+ // go back to edit form
146
+ $this->_redirect('*/*/edit', array('vendor_id' => $id));
147
+ return;
148
+ }
149
+ }
150
+ // display error message
151
+ Mage::getSingleton('adminhtml/session')->addError(Mage::helper('logicbroker')->__('Unable to find a vendor to delete.'));
152
+ // go to grid
153
+ $this->_redirect('*/*/');
154
+ }
155
+
156
+
157
+ /**
158
+ * Export vendor in csv format
159
+ */
160
+ public function exportCsvAction()
161
+ {
162
+ $fileName = 'vendor.csv';
163
+ $content = $this->getLayout()->createBlock('logicbroker/adminhtml_logicbroker_grid')
164
+ ->getCsvFile();
165
+
166
+ $this->_prepareDownloadResponse($fileName, $content);
167
+ }
168
+
169
+ /**
170
+ * Export vendor in Excel format
171
+ */
172
+ public function exportXmlAction()
173
+ {
174
+ $fileName = 'vendor.xml';
175
+ $content = $this->getLayout()->createBlock('logicbroker/adminhtml_logicbroker_grid')
176
+ ->getExcelFile($fileName);
177
+
178
+ $this->_prepareDownloadResponse($fileName, $content);
179
+ }
180
+
181
+ public function validateajaxrequestAction()
182
+ {
183
+
184
+ $paramsArray = $this->getRequest()->getParams();
185
+ $validation = Mage::getModel('logicbroker/logicbroker');
186
+ $result = $validation->validation($paramsArray['groups']['integration']['fields']);
187
+ //$result['message'] = 'JAI hohohoh';
188
+ $result = Mage::helper('core')->jsonEncode($result);
189
+ Mage::app()->getResponse()->setBody($result);
190
+
191
+ }
192
+
193
+ }
includes/src/Logicbroker_Fulfillment_Block_Adminhtml_Logicbroker.php ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Logicbroker
5
+ *
6
+ * @category Community
7
+ * @package Logicbroker_Fulfillment
8
+ */
9
+ class Logicbroker_Fulfillment_Block_Adminhtml_Logicbroker extends Mage_Adminhtml_Block_Widget_Grid_Container
10
+ {
11
+ public function __construct()
12
+ {
13
+ $this->_controller = 'adminhtml_logicbroker';
14
+ $this->_blockGroup = 'logicbroker';
15
+ $this->_headerText = Mage::helper('logicbroker')->__('Vendor Manager');
16
+ $this->_addButtonLabel = Mage::helper('logicbroker')->__('Add Vendor');
17
+ parent::__construct();
18
+ }
19
+ }
includes/src/Logicbroker_Fulfillment_Block_Adminhtml_Logicbroker_Edit.php ADDED
@@ -0,0 +1,100 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Logicbroker
5
+ *
6
+ * @category Community
7
+ * @package Logicbroker_Fulfillment
8
+ */
9
+
10
+ class Logicbroker_Fulfillment_Block_Adminhtml_Logicbroker_Edit extends Mage_Adminhtml_Block_Widget_Form_Container
11
+ {
12
+ public function __construct()
13
+ {
14
+
15
+
16
+ $this->_objectId = 'vendor_id';
17
+ $this->_blockGroup = 'logicbroker';
18
+ $this->_controller = 'adminhtml_logicbroker';
19
+ parent::__construct();
20
+
21
+ $this->_updateButton('save', 'label', Mage::helper('logicbroker')->__('Save Vendor'));
22
+ $this->_updateButton('delete', 'label', Mage::helper('logicbroker')->__('Delete Vendor'));
23
+
24
+ $this->_addButton('saveandcontinue', array(
25
+ 'label' => Mage::helper('adminhtml')->__('Save And Continue Edit'),
26
+ 'onclick' => 'saveAndContinueEdit()',
27
+ 'class' => 'save',
28
+ ), -100);
29
+ $this->_removeButton('delete');
30
+ $this->_removeButton('reset');
31
+ $script = $isUpdate='';
32
+ if( Mage::registry('logicbroker_data') && Mage::registry('logicbroker_data')->getVendorId() )
33
+ {
34
+ $isUpdate = "if($('is_update')) $('is_update').value = '1';";
35
+ }
36
+
37
+ if(Mage::getModel('logicbroker/supplier')->isVendorSubmitted())
38
+ {
39
+ $message = '<p><ul class="messages"><li class="error-msg"><ul><li><span>'.$this->__('You have unsubmitted changes.').'</span></li></ul></li></ul></p>';
40
+ $script = "$$('.main-col-inner .content-header')[0].insert({after:'{$message}'});";
41
+ }
42
+ $vendorAttributeId = Mage::getModel('logicbroker/supplier')->getVendorAttributeId();
43
+ $link = Mage::helper('logicbroker')->getConfigObject('apiconfig/helpurl/link');
44
+
45
+ $string = 'Enter new code here';
46
+ //$blank = '';
47
+ $this->_formScripts[] = "
48
+ {$isUpdate}
49
+ {$script}
50
+ $('need_help').href = '{$link}';
51
+ $('need_help').target = '_blank';
52
+ $('need_help').insert('Contact Us');
53
+ function saveAndContinueEdit(){
54
+ editForm.submit($('edit_form').action+'back/edit/');
55
+ }
56
+
57
+ $('magento_vendor_attribute_id').value = '{$vendorAttributeId}';
58
+ function checkisnew(value){
59
+ if(value == 'addnew' && $('add_new_option') == null)
60
+ {
61
+ $('magento_vendor_code').insert({
62
+ after: new Element('input', {type: 'text',
63
+ name:'addnewoption',class:'input-text',id:'add_new_option',value:'{$string}',
64
+ onfocus:'if(this.value==\"{$string}\"){this.value=\"\"; this.addClassName(\"required-entry\")}; '
65
+ })
66
+ });
67
+ Form.Element.focus('add_new_option');
68
+ }else
69
+ {
70
+ if($('add_new_option'))
71
+ {
72
+ $('add_new_option').remove();
73
+
74
+ }
75
+ if($('advice-required-entry-add_new_option'))
76
+ {
77
+ $('advice-required-entry-add_new_option').remove();
78
+ }
79
+ }
80
+ }
81
+ Validation.addAllThese([
82
+
83
+ ['validate-ftp-url-logicbroker', 'Please enter a valid URL. Protocol is required (ftp://, ftps:// )', function (v) {
84
+ v = (v || '').replace(/^\s+/, '').replace(/\s+$/, '');
85
+ return Validation.get('IsEmpty').test(v) || /^(ftp|ftps):\/\/(([A-Z0-9]([A-Z0-9_-]*[A-Z0-9]|))(\.[A-Z0-9]([A-Z0-9_-]*[A-Z0-9]|))*)(:(\d+))?(\/[A-Z0-9~](([A-Z0-9_~-]|\.)*[A-Z0-9~]|))*\/?(.*)?$/i.test(v)
86
+ }]
87
+ ]);
88
+ ";
89
+ }
90
+
91
+ public function getHeaderText()
92
+ {
93
+ if( Mage::registry('logicbroker_data') && Mage::registry('logicbroker_data')->getVendorId() ) {
94
+ return Mage::helper('logicbroker')->__("Edit Vendor", $this->htmlEscape(Mage::registry('logicbroker_data')->getTitle()));
95
+ } else {
96
+ return Mage::helper('logicbroker')->__('Add Vendor');
97
+ }
98
+ }
99
+
100
+ }
includes/src/Logicbroker_Fulfillment_Block_Adminhtml_Logicbroker_Edit_Form.php ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Logicbroker
5
+ *
6
+ * @category Community
7
+ * @package Logicbroker_Fulfillment
8
+ */
9
+
10
+ class Logicbroker_Fulfillment_Block_Adminhtml_Logicbroker_Edit_Form extends Mage_Adminhtml_Block_Widget_Form
11
+ {
12
+ protected function _prepareForm()
13
+ {
14
+ $form = new Varien_Data_Form(array(
15
+ 'id' => 'edit_form',
16
+ 'action' => $this->getUrl('*/*/save', array('vendor_id' => $this->getRequest()->getParam('vendor_id'))),
17
+ 'method' => 'post',
18
+ 'enctype' => 'multipart/form-data'
19
+ )
20
+ );
21
+
22
+ $form->setUseContainer(true);
23
+ $this->setForm($form);
24
+ return parent::_prepareForm();
25
+ }
26
+ }
includes/src/Logicbroker_Fulfillment_Block_Adminhtml_Logicbroker_Edit_Tab_Form.php ADDED
@@ -0,0 +1,176 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Logicbroker
5
+ *
6
+ * @category Community
7
+ * @package Logicbroker_Fulfillment
8
+ */
9
+
10
+ class Logicbroker_Fulfillment_Block_Adminhtml_Logicbroker_Edit_Tab_Form extends Mage_Adminhtml_Block_Widget_Form
11
+ {
12
+
13
+ protected function _prepareForm()
14
+ {
15
+ $form = new Varien_Data_Form();
16
+ $this->setForm($form);
17
+ $fieldset = $form->addFieldset('logicbroker_form', array('legend'=>Mage::helper('logicbroker')->__('Vendor Information')));
18
+ //$data = $form->setValues(Mage::registry('logicbroker_data')->getData());
19
+
20
+ $fieldset->addField('is_update', 'hidden', array(
21
+ 'name' => 'is_update',
22
+ ));
23
+ $fieldset->addField('company_id', 'text', array(
24
+ 'label' => Mage::helper('logicbroker')->__('logicbroker Company ID'),
25
+ 'name' => 'company_id',
26
+ 'note'=>'From the logicbroker portal - optional if you do not have an account'
27
+
28
+ ));
29
+ $fieldset->addField('address1', 'text', array(
30
+ 'label' => Mage::helper('logicbroker')->__('Address 1'),
31
+ 'class' => 'required-entry',
32
+ 'required' => true,
33
+ 'name' => 'address1',
34
+ ));
35
+ $fieldset->addField('address2', 'text', array(
36
+ 'label' => Mage::helper('logicbroker')->__('Address 2'),
37
+ 'name' => 'address2',
38
+ ));
39
+ $fieldset->addField('city', 'text', array(
40
+ 'label' => Mage::helper('logicbroker')->__('City'),
41
+ 'class' => 'required-entry',
42
+ 'required' => true,
43
+ 'name' => 'city',
44
+ ));
45
+ $fieldset->addField('state', 'text', array(
46
+ 'label' => Mage::helper('logicbroker')->__('State'),
47
+ 'class' => 'required-entry',
48
+ 'required' => true,
49
+ 'name' => 'state',
50
+ ));
51
+ $fieldset->addField('zip', 'text', array(
52
+ 'label' => Mage::helper('logicbroker')->__('Zip'),
53
+ 'class' => 'required-entry validate-digits',
54
+ 'required' => true,
55
+ 'name' => 'zip',
56
+ ));
57
+ $fieldset->addField('country', 'select', array(
58
+ 'label' => Mage::helper('logicbroker')->__('Country'),
59
+ 'class' => 'required-entry validate-select',
60
+ 'required' => true,
61
+ 'name' => 'country',
62
+ 'values' => Mage::getModel('adminhtml/system_config_source_country')->toOptionArray(),
63
+ 'default' => ''
64
+ ));
65
+ $fieldset->addField('edi_qualifier', 'select', array(
66
+ 'label' => Mage::helper('logicbroker')->__('EDI Qualifier'),
67
+ 'class' => 'required-entry validate-select',
68
+ 'required' => true,
69
+ 'name' => 'edi_qualifier',
70
+ 'values' => Mage::getModel('logicbroker/system_config_source_ediqualifier')->toOptionArray(),
71
+ 'default' => ''
72
+ ));
73
+ $fieldset->addField('edi_identifier', 'text', array(
74
+ 'label' => Mage::helper('logicbroker')->__('EDI Identifier'),
75
+ 'class' => 'required-entry',
76
+ 'required' => true,
77
+ 'name' => 'edi_identifier',
78
+ ));
79
+
80
+ $fieldset->addField('magento_vendor_attribute_id', 'hidden', array(
81
+ 'name' => 'magento_vendor_attribute_id',
82
+
83
+
84
+ ));
85
+ $fieldset->addField('magento_vendor_code', 'select', array(
86
+ 'label' => Mage::helper('logicbroker')->__('Vendor Code'),
87
+ 'class' => 'required-entry validate-select',
88
+ 'required' => true,
89
+ 'onchange' => 'checkisnew(value)',
90
+ 'name' => 'magento_vendor_code',
91
+ 'values' => Mage::getModel('logicbroker/system_config_source_Optionvalues')->toOptionArray(),
92
+ 'default' => ''
93
+ ));
94
+ $fieldset->addField('file_directory_inbound', 'text', array(
95
+ 'label' => Mage::helper('logicbroker')->__('File Directory Inbound'),
96
+ 'class' => 'required-entry',
97
+ 'required' => true,
98
+ 'name' => 'file_directory_inbound',
99
+ ));
100
+ $fieldset->addField('file_directory_outbound', 'text', array(
101
+ 'label' => Mage::helper('logicbroker')->__('File Directory Outbound'),
102
+ 'class' => 'required-entry',
103
+ 'required' => true,
104
+ 'name' => 'file_directory_outbound',
105
+ ));
106
+ $fieldset->addField('ftp_address', 'text', array(
107
+ 'label' => Mage::helper('logicbroker')->__('FTP Address'),
108
+ 'class' => 'required-entry validate-ftp-url-logicbroker',
109
+ 'required' => true,
110
+ 'name' => 'ftp_address',
111
+ ));
112
+ $fieldset->addField('ftp_username', 'text', array(
113
+ 'label' => Mage::helper('logicbroker')->__('FTP Username'),
114
+ 'class' => 'required-entry',
115
+ 'required' => true,
116
+ 'name' => 'ftp_username',
117
+ ));
118
+ $fieldset->addField('ftp_password', 'password', array(
119
+ 'label' => Mage::helper('logicbroker')->__('FTP Password'),
120
+ 'class' => 'required-entry',
121
+ 'required' => true,
122
+ 'name' => 'ftp_password',
123
+ ));
124
+ $fieldset->addField('ftp_protocol', 'select', array(
125
+ 'label' => Mage::helper('logicbroker')->__('FTP Protocol'),
126
+ 'class' => 'required-entry validate-select',
127
+ 'required' => true,
128
+ 'name' => 'ftp_protocol',
129
+ 'values' =>array(
130
+ array('value' => '', 'label'=>Mage::helper('adminhtml')->__('')),
131
+ array('value' => 'ftp', 'label'=>Mage::helper('adminhtml')->__('FTP')),
132
+ array('value' => 'ftpes', 'label'=>Mage::helper('adminhtml')->__('FTPES')),
133
+ ),
134
+
135
+ ));
136
+ $fieldset->addField('firstname', 'text', array(
137
+ 'label' => Mage::helper('logicbroker')->__('Contact First Name'),
138
+ 'class' => 'required-entry',
139
+ 'required' => true,
140
+ 'name' => 'firstname',
141
+ ));
142
+ $fieldset->addField('lastname', 'text', array(
143
+ 'label' => Mage::helper('logicbroker')->__('Contact Last Name'),
144
+ 'class' => 'required-entry',
145
+ 'required' => true,
146
+ 'name' => 'lastname',
147
+ ));
148
+ $fieldset->addField('email', 'text', array(
149
+ 'label' => Mage::helper('logicbroker')->__('Contact Email'),
150
+ 'class' => 'required-entry validate-email',
151
+ 'required' => true,
152
+ 'name' => 'email',
153
+ ));
154
+ $fieldset->addField('phone', 'text', array(
155
+ 'label' => Mage::helper('logicbroker')->__('Contact Phone'),
156
+ 'class' => 'required-entry validate-phoneStrict',
157
+ 'required' => true,
158
+ 'name' => 'phone',
159
+ ));
160
+
161
+ $fieldset->addField('need_help', 'link', array(
162
+ 'label' => $this->__('Need Help?'),
163
+ 'value' => ''
164
+
165
+ ));
166
+
167
+ if ( Mage::getSingleton('adminhtml/session')->getLogicbrokerData() )
168
+ {
169
+ $form->setValues(Mage::getSingleton('adminhtml/session')->getLogicbrokerData());
170
+ Mage::getSingleton('adminhtml/session')->setLogicbrokerData(null);
171
+ } elseif ( Mage::registry('logicbroker_data') ) {
172
+ $form->setValues(Mage::registry('logicbroker_data')->getData());
173
+ }
174
+ return parent::_prepareForm();
175
+ }
176
+ }
includes/src/Logicbroker_Fulfillment_Block_Adminhtml_Logicbroker_Edit_Tabs.php ADDED
@@ -0,0 +1,32 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Logicbroker
5
+ *
6
+ * @category Community
7
+ * @package Logicbroker_Fulfillment
8
+ */
9
+
10
+ class Logicbroker_Fulfillment_Block_Adminhtml_Logicbroker_Edit_Tabs extends Mage_Adminhtml_Block_Widget_Tabs
11
+ {
12
+
13
+
14
+ public function __construct()
15
+ {
16
+ parent::__construct();
17
+ $this->setId('logicbroker_tabs');
18
+ $this->setDestElementId('edit_form');
19
+ $this->setTitle(Mage::helper('logicbroker')->__('Vendor Information'));
20
+ }
21
+
22
+ protected function _beforeToHtml()
23
+ {
24
+ $this->addTab('form_section', array(
25
+ 'label' => Mage::helper('logicbroker')->__('Vendor Information'),
26
+ 'title' => Mage::helper('logicbroker')->__('Vendor Information'),
27
+ 'content' => $this->getLayout()->createBlock('logicbroker/adminhtml_logicbroker_edit_tab_form')->toHtml(),
28
+ ));
29
+
30
+ return parent::_beforeToHtml();
31
+ }
32
+ }
includes/src/Logicbroker_Fulfillment_Block_Adminhtml_Logicbroker_Grid.php ADDED
@@ -0,0 +1,129 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Logicbroker
5
+ *
6
+ * @category Community
7
+ * @package Logicbroker_Fulfillment
8
+ */
9
+
10
+ class Logicbroker_Fulfillment_Block_Adminhtml_Logicbroker_Grid extends Mage_Adminhtml_Block_Widget_Grid
11
+ {
12
+ public function __construct()
13
+ {
14
+ parent::__construct();
15
+ $this->setId('logicbrokergrid');
16
+ $this->setDefaultSort('vendor_id');
17
+ $this->setDefaultDir('ASC');
18
+ $this->setUseAjax(true);
19
+ $this->setSaveParametersInSession(true);
20
+ }
21
+
22
+ protected function _prepareCollection()
23
+ {
24
+ $collection = Mage::getModel('logicbroker/supplier')->getCollection()->addFieldToFilter('status',array('neq'=>'deleted'));
25
+ $this->setCollection($collection);
26
+ return parent::_prepareCollection();
27
+ }
28
+
29
+ protected function _prepareColumns()
30
+ {
31
+ $this->addColumn('vendor_id', array(
32
+ 'header' => Mage::helper('logicbroker')->__('Magento Id'),
33
+ 'align' =>'right',
34
+ 'width' => '50px',
35
+ 'index' => 'vendor_id',
36
+ ));
37
+ $this->addColumn('company_id', array(
38
+ 'header' => Mage::helper('logicbroker')->__('logicbroker Id'),
39
+ 'align' =>'right',
40
+ 'width' => '50px',
41
+ //'type' => 'text',
42
+ 'index' => 'company_id',
43
+ //'options' => Mage::getModel('logicbroker/supplier')->getCompanyids(),
44
+ ));
45
+ $this->addColumn('address1', array(
46
+ 'header' => Mage::helper('logicbroker')->__('Address'),
47
+ 'align' =>'right',
48
+ 'width' => '50px',
49
+ 'index' => 'address1',
50
+ ));
51
+
52
+ $this->addColumn('magento_vendor_code', array(
53
+ 'header' => Mage::helper('logicbroker')->__('Vendor Attribute Value'),
54
+ 'align' =>'left',
55
+ 'width' => '80px',
56
+ 'index' => 'magento_vendor_code',
57
+ ));
58
+
59
+ $this->addColumn('firstname', array(
60
+ 'header' => Mage::helper('logicbroker')->__('Firstname'),
61
+ 'align' =>'left',
62
+ 'width' => '80px',
63
+ 'index' => 'firstname',
64
+ ));
65
+
66
+ $this->addColumn('lastname', array(
67
+ 'header' => Mage::helper('logicbroker')->__('Lastname'),
68
+ 'align' =>'left',
69
+ 'width' => '80px',
70
+ 'index' => 'lastname',
71
+ ));
72
+
73
+ $this->addColumn('email', array(
74
+ 'header' => Mage::helper('logicbroker')->__('Email'),
75
+ 'align' =>'left',
76
+ 'width' => '80px',
77
+ 'index' => 'email',
78
+ ));
79
+ $this->addColumn('phone', array(
80
+ 'header' => Mage::helper('logicbroker')->__('Phone'),
81
+ 'align' =>'left',
82
+ 'width' => '80px',
83
+ 'index' => 'phone',
84
+ ));
85
+
86
+ $this->addColumn('action',
87
+ array(
88
+ 'header' => Mage::helper('logicbroker')->__('Action'),
89
+ 'width' => '100',
90
+ 'type' => 'textaction',
91
+ 'getter' => 'getVendorId',
92
+ 'actions' => array(
93
+ array(
94
+ 'caption' => Mage::helper('logicbroker')->__('edit'),
95
+ 'url' => array('base'=> '*/*/edit'),
96
+ 'field' => 'vendor_id'
97
+ ),
98
+ array(
99
+ 'caption' => Mage::helper('logicbroker')->__('delete'),
100
+ 'url' => array('base'=> '*/*/delete'),
101
+ 'field' => 'vendor_id',
102
+ 'confirm' =>'Are you sure to delete vendor?'
103
+
104
+ )
105
+ ),
106
+ 'filter' => false,
107
+ 'sortable' => false,
108
+ 'index' => 'stores',
109
+ 'is_system' => true,
110
+ 'renderer' => 'Logicbroker_Fulfillment_Block_Adminhtml_Widget_Grid_Column_Renderer_Textaction'
111
+ ));
112
+
113
+
114
+ $this->addExportType('*/*/exportCsv', Mage::helper('logicbroker')->__('CSV'));
115
+ $this->addExportType('*/*/exportXml', Mage::helper('logicbroker')->__('XML'));
116
+
117
+ return parent::_prepareColumns();
118
+ }
119
+
120
+ public function getRowUrl($row)
121
+ {
122
+ return $this->getUrl('*/*/edit', array('vendor_id' => $row->getVendorId()));
123
+ }
124
+ public function getGridUrl()
125
+ {
126
+ return $this->getUrl('*/*/grid', array('_current'=>true));
127
+ }
128
+
129
+ }
includes/src/Logicbroker_Fulfillment_Block_Adminhtml_System_Config_Fieldset_Hint.php ADDED
@@ -0,0 +1,134 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Logicbroker
4
+ *
5
+ * @category Community
6
+ * @package Logicbroker_Fulfillment
7
+ */
8
+ class Logicbroker_Fulfillment_Block_Adminhtml_System_Config_Fieldset_Hint
9
+ extends Mage_Adminhtml_Block_Abstract
10
+ implements Varien_Data_Form_Element_Renderer_Interface
11
+ {
12
+ protected $_template = 'logicbroker/system/config/fieldset/hint.phtml';
13
+
14
+ /**
15
+ * Render fieldset html
16
+ *
17
+ * @param Varien_Data_Form_Element_Abstract $element
18
+ * @return string
19
+ */
20
+
21
+
22
+
23
+
24
+
25
+ public function getGroup($element = null)
26
+ {
27
+ if (is_null($element)) {
28
+ $element = $this->getElement();
29
+ }
30
+ if ($element && $element->getGroup() instanceof Mage_Core_Model_Config_Element) {
31
+ return $element->getGroup();
32
+ }
33
+
34
+ return new Mage_Core_Model_Config_Element('<config/>');
35
+ }
36
+
37
+ public function render(Varien_Data_Form_Element_Abstract $element)
38
+ {
39
+ //print_r($element->getElement('zip'));
40
+ $groupConfig = $this->getGroup($element)->asArray();
41
+ $html .= $this->genrateHtml($groupConfig['fields'],$element);
42
+ //print_r($element->getForm()->getElements());
43
+ $elementHtmlObject = $element->getElementHtml();
44
+ $elementOriginalData = $element->getOriginalData();
45
+ if (isset($elementOriginalData['page_heading'])) {
46
+ $this->setPageHeading($elementOriginalData['page_heading']);
47
+ }
48
+ if ($elementHtmlObject) {
49
+ $this->setHtmlSupplier($elementHtmlObject);
50
+ }
51
+
52
+ $html .= $this->toHtml();
53
+ return $html;
54
+ }
55
+
56
+ public function genrateHtml($fields,$element)
57
+ {
58
+ $html .= $this->_getHeaderHtml($element);
59
+ $html .= $this->_getContentHtml($fields);
60
+ $html .= $this->_getFooterHtml($element);
61
+
62
+ return $html;
63
+ }
64
+
65
+ public function _getContentHtml($fields)
66
+ {
67
+ foreach($fields as $key=>$val)
68
+ {
69
+ if($val['frontend_type'] == 'text')
70
+ {
71
+ $html .= $this->_getTextBoxHtml($key,$val);
72
+
73
+ }
74
+
75
+ if($val['frontend_type'] == 'select')
76
+ {
77
+ $html .= $this->_getSelectBoxHtml($key,$val);
78
+ }
79
+ }
80
+ return $html;
81
+ }
82
+
83
+ protected function _getHeaderHtml($element)
84
+ {
85
+ $html = '<h4 class="icon-head head-edit-form">'.$element->getLegend().'</h4>';
86
+ $html.= '<fieldset class="config" id="'.$element->getHtmlId().'">';
87
+ $html.= '<legend>'.$element->getLegend().'</legend>';
88
+
89
+ // field label column
90
+ $html.= '<table cellspacing="0"><colgroup class="label" /><colgroup class="value" />';
91
+ $html.= '<tbody>';
92
+
93
+ return $html;
94
+
95
+ }
96
+
97
+ protected function _getFooterHtml($element)
98
+ {
99
+ $html = '</tbody></table></fieldset>';
100
+ return $html;
101
+
102
+ }
103
+
104
+ protected function _getConfigurationValue($val)
105
+ {
106
+ return isset($val) ? $val:'';
107
+ }
108
+
109
+ protected function _getTextBoxHtml($key,$val)
110
+ {
111
+ return '<tr id="row_'.$key.'"><td class="label"><label for="'.$key.'">'.$this->_getConfigurationValue($val['label']).'</label></td><td class="value"><input id="'.$key.'" name="'.$key.'" value="" class="input-text '.$this->_getConfigurationValue($val['validate']).'" type="text"></td><td class=""></td></tr>';
112
+
113
+ /* return '<div id="row_'.$key.'"><div style="200px;float:left;" class="label"><label style="display: block;width: 185px;padding-right: 15px;padding-top: 1px;"for="'.$key.'">'.$this->_getConfigurationValue($val['label']).'</label></div><div style="300px"class="value"><input style="274px" id="'.$key.'" name="'.$key.'" value="" class="input-text '.$this->_getConfigurationValue($val['validate']).'" type="text">
114
+ </div></div><div clear="both"></div>';*/
115
+
116
+ }
117
+
118
+ protected function _getSelectBoxHtml($key,$val)
119
+ {
120
+ $optionArray = Mage::getSingleton("adminhtml/system_config_source_country")->toOptionArray();
121
+
122
+ foreach($optionArray as $code=>$label){
123
+ $optionHtml .= '<option value = "'.$label['value'].'">'.$label['label'].'</option>';
124
+
125
+ }
126
+
127
+ return '<tr id="row_'.$key.'"><td class="label"><label for="'.$key.'">'.$this->_getConfigurationValue($val['label']).'</label></td><td class="value"><select id="'.$key.'" name="'.$key.'" class=" select '.$this->_getConfigurationValue($val['validate']).'">'.$optionHtml.'</select></td><td class=""></td></tr>';
128
+ /*return '<div id="row_'.$key.'"><div class="label"><label for="'.$key.'">'.$this->_getConfigurationValue($val['label']).'</label></div><div class="value"><select id="'.$key.'" name="'.$key.'" class="select '.$this->_getConfigurationValue($val['validate']).'">'.$optionHtml.'
129
+ </select>
130
+ </div></div>';*/
131
+
132
+ }
133
+
134
+ }
includes/src/Logicbroker_Fulfillment_Block_Adminhtml_System_Config_Submitbutton.php ADDED
@@ -0,0 +1,100 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Logicbroker
4
+ *
5
+ * @category Community
6
+ * @package Logicbroker_Fulfillment
7
+ */
8
+ class Logicbroker_Fulfillment_Block_Adminhtml_System_Config_Submitbutton
9
+ extends Mage_Adminhtml_Block_System_Config_Form_Field
10
+ {
11
+ /*
12
+ * Set template
13
+ */
14
+ protected function _construct()
15
+ {
16
+ parent::_construct();
17
+ $this->setTemplate('logicbroker/system/config/submitbutton.phtml');
18
+ }
19
+
20
+ /**
21
+ * Remove scope label
22
+ *
23
+ * @param Varien_Data_Form_Element_Abstract $element
24
+ * @return string
25
+ */
26
+ public function render(Varien_Data_Form_Element_Abstract $element)
27
+ {
28
+ $element->unsScope()->unsCanUseWebsiteValue()->unsCanUseDefaultValue();
29
+ return parent::render($element);
30
+ }
31
+
32
+ /**
33
+ * Return element html
34
+ *
35
+ * @param Varien_Data_Form_Element_Abstract $element
36
+ * @return string
37
+ */
38
+ protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
39
+ {
40
+ return $this->_toHtml();
41
+ }
42
+
43
+ /**
44
+ * Return ajax url for synchronize button
45
+ *
46
+ * @return string
47
+ */
48
+ public function getAjaxSyncUrl()
49
+ {
50
+ return Mage::getUrl('logicbroker/adminhtml_logicbroker/validateajaxrequest');
51
+ }
52
+
53
+
54
+ /**
55
+ * Generate synchronize button html
56
+ *
57
+ * @return string
58
+ */
59
+ public function getSubmitButtonHtml()
60
+ {
61
+ $button = $this->getLayout()->createBlock('adminhtml/widget_button')
62
+ ->setData(array(
63
+ 'id' => 'submit_button',
64
+ 'label' => $this->helper('adminhtml')->__('Submit to logicbroker '),
65
+ 'onclick' => 'javascript:synchronize(this.id); return false;',
66
+ 'style' => 'float:right'
67
+ ));
68
+
69
+ return $button->toHtml();
70
+ }
71
+
72
+ /**
73
+ * Generate Save button html
74
+ *
75
+ * @return string
76
+ */
77
+ public function getSaveButtonHtml()
78
+ {
79
+ $button = $this->getLayout()->createBlock('adminhtml/widget_button')
80
+ ->setData(array(
81
+ 'id' => 'save_button',
82
+ 'label' => $this->helper('adminhtml')->__('Save for Later'),
83
+ 'onclick' => 'javascript:synchronize(this.id); return false;',
84
+
85
+ ));
86
+
87
+ return $button->toHtml();
88
+ }
89
+
90
+ public function getTermsAndConditionsUrl()
91
+ {
92
+ return Mage::helper('logicbroker')->getConfigObject('apiconfig/termsandconditions/link');
93
+ }
94
+
95
+ public function getHelpUrl()
96
+ {
97
+ return Mage::helper('logicbroker')->getConfigObject('apiconfig/helpurl/link');
98
+ }
99
+
100
+ }
includes/src/Logicbroker_Fulfillment_Block_Adminhtml_Widget_Grid_Column_Renderer_Textaction.php ADDED
@@ -0,0 +1,37 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Adminhtml grid item renderer
5
+ *
6
+ * @category Orange
7
+ * @package Orange_Prepaidcards
8
+ * @author Anil Pawar <anilpa@cybage.com>
9
+ */
10
+
11
+ class Logicbroker_Fulfillment_Block_Adminhtml_Widget_Grid_Column_Renderer_Textaction extends Mage_Adminhtml_Block_Widget_Grid_Column_Renderer_Action
12
+ {
13
+
14
+ /**
15
+ * Renders column
16
+ *
17
+ * @param Varien_Object $row
18
+ * @return string
19
+ */
20
+ public function render(Varien_Object $row)
21
+ {
22
+ $actions = $this->getColumn()->getActions();
23
+ if ( empty($actions) || !is_array($actions) ) {
24
+ return '&nbsp;';
25
+ }
26
+ $out="";
27
+ if(!$this->getColumn()->getNoLink()) {
28
+ foreach ($actions as $action) {
29
+ if ( is_array($action) ) {
30
+ $out .= "&nbsp;&nbsp;&nbsp;".$this->_toLinkHtml($action, $row);
31
+ }
32
+ }
33
+ }
34
+ return $out;
35
+
36
+ }
37
+ }
includes/src/Logicbroker_Fulfillment_Helper_Data.php ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Logicbroker
5
+ *
6
+ *
7
+ *
8
+ */
9
+
10
+ class Logicbroker_Fulfillment_Helper_Data extends Mage_Core_Helper_Abstract
11
+ {
12
+ public function getConfigObject($nodeName = null)
13
+ {
14
+ return trim(Mage::getConfig()->getNode($nodeName)->__toString());
15
+ }
16
+ }
17
+
includes/src/Logicbroker_Fulfillment_Model_Abstract.php ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Logicbroker
5
+ *
6
+ * @category Community
7
+ * @package Logicbroker_Fulfillment
8
+ */
9
+
10
+ abstract class Logicbroker_Fulfillment_Model_Abstract
11
+ {
12
+
13
+ public function send($attachment,$fieldSetData) {
14
+
15
+ }
16
+
17
+ public function prepareData($fieldsetData)
18
+ {
19
+
20
+ }
21
+ }
includes/src/Logicbroker_Fulfillment_Model_Apicreate.php ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Logicbroker
5
+ *
6
+ * @category Community
7
+ * @package Logicbroker_Fulfillment
8
+ */
9
+
10
+ class Logicbroker_Fulfillment_Model_Apicreate {
11
+ //put your code here
12
+ }
13
+
14
+ ?>
includes/src/Logicbroker_Fulfillment_Model_Email.php ADDED
@@ -0,0 +1,71 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Logicbroker
5
+ *
6
+ * @category Community
7
+ * @package Logicbroker_Fulfillment
8
+ */
9
+
10
+ class Logicbroker_Fulfillment_Model_Email extends Logicbroker_Fulfillment_Model_Abstract{
11
+
12
+ public function prepareData($fieldsetData)
13
+ {
14
+ $excelxmlModel = Mage::getModel('logicbroker/excelxml');
15
+ $response = $excelxmlModel->getExcelFile($fieldsetData);
16
+ if(!is_array($response) && !$response)
17
+ {
18
+ Mage::throwException('Not able to genrate excel XML');
19
+ }
20
+
21
+ return $response['value'];
22
+
23
+ }
24
+
25
+
26
+
27
+ public function send($attachment = null,$fieldsetData) {
28
+ try {
29
+
30
+ $fieldsetData['isnewreg'] = ($attachment)?0:1;
31
+
32
+ $postObject = new Varien_Object();
33
+ $postObject->setData($fieldsetData);
34
+ $mailTemplate = Mage::getModel('core/email_template');
35
+ if($attachment)
36
+ {
37
+ $content = file_get_contents($attachment);
38
+ $content = str_replace('></',">\n</",$content);
39
+ // this is for to set the file format
40
+ $at = new Zend_Mime_Part($content);
41
+
42
+ $at->type = 'application/xml'; // if u have PDF then it would like -> 'application/pdf'
43
+ $at->disposition = Zend_Mime::DISPOSITION_INLINE;
44
+ $at->encoding = Zend_Mime::ENCODING_8BIT;
45
+ $at->filename = 'logicbroker'.date('ymdHis').'.xml';
46
+ $mailTemplate->getMail()->addAttachment($at);
47
+ //$emailTemplate->_mail->addAttachment($at);
48
+ }
49
+ /* @var $mailTemplate Mage_Core_Model_Email_Template */
50
+ $mailTemplate->setDesignConfig(array('area' => 'frontend'))
51
+ ->sendTransactional(
52
+ 'logicbroker_email_email_template',
53
+ 'general',
54
+ Mage::helper('logicbroker')->getConfigObject('apiconfig/email/toaddress'),
55
+ Mage::helper('logicbroker')->getConfigObject('apiconfig/email/toname'),
56
+ array('templatevar' => $postObject)
57
+ );
58
+
59
+ if (!$mailTemplate->getSentSuccess()) {
60
+ return false;
61
+ //throw new Exception();
62
+ }
63
+
64
+ return true;//echo 'Mail send successfully with attachment file name -: ' . $attachment . "\n";
65
+ } catch (Exception $e) {
66
+ return false;//$e->getMassage();
67
+ }
68
+ }
69
+
70
+ }
71
+ ?>
includes/src/Logicbroker_Fulfillment_Model_Excelxml.php ADDED
@@ -0,0 +1,202 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Logicbroker
5
+ *
6
+ * @category Community
7
+ * @package Logicbroker_Fulfillment
8
+ */
9
+
10
+ class Logicbroker_Fulfillment_Model_Excelxml{
11
+
12
+
13
+ protected function prepareExportCollection()
14
+ {
15
+ $fieldSelect = Mage::helper('logicbroker')->getConfigObject('apiconfig/fieldstoexport/data');
16
+ $selectFields = array();
17
+ foreach(explode(',',$fieldSelect) as $values)
18
+ {
19
+ $selectFields[] = $values;
20
+
21
+ }
22
+ $supplierCollection = Mage::getModel('logicbroker/supplier')->getCollection()->addFieldToFilter('status','')->addFieldToSelect($selectFields);
23
+ $supplierData = $supplierCollection->getData();
24
+
25
+ if(count($supplierData) > 0)
26
+ {
27
+
28
+ return $supplierData;
29
+ }
30
+ return 0;
31
+ }
32
+
33
+ public function getConfigObject($nodeName = null)
34
+ {
35
+ return Mage::getConfig()->getNode($nodeName);
36
+ }
37
+
38
+ protected function _getExportHeadersConfiguration($fieldsetData)
39
+ {
40
+ $headers = array();
41
+ $mode = '';
42
+
43
+ $baseUrl = Mage::getBaseUrl('web');
44
+
45
+ if($baseUrl == $fieldsetData['your_production_store_url'])
46
+ {
47
+ $mode = Mage::getModel('logicbroker/logicbroker')->checkProductionMode($fieldsetData);
48
+ }elseif($baseUrl == $fieldsetData['your_staging_store_url'])
49
+ {
50
+ $mode = 'staging';
51
+ }else
52
+ {
53
+ $mode = 'staging';
54
+ }
55
+
56
+
57
+ $headers = array('companyid','key',$mode);
58
+
59
+ return $headers;
60
+ }
61
+
62
+ protected function _getExportRowsConfiguration($adapter,$parser,$fieldsetData)
63
+ {
64
+ $mode = '';
65
+
66
+ $baseUrl = Mage::getBaseUrl('web');
67
+
68
+ if($baseUrl == $fieldsetData['your_production_store_url'])
69
+ {
70
+ Mage::getModel('logicbroker/logicbroker')->checkProductionMode($fieldsetData);
71
+ $mode = 'your_production_store_url';
72
+ }elseif($baseUrl == $fieldsetData['your_staging_store_url'])
73
+ {
74
+ $mode = 'your_staging_store_url';
75
+ }else
76
+ {
77
+ $mode = 'your_staging_store_url';
78
+ }
79
+ $apiPassword = Mage::registry('api_password');
80
+ $columns = array('MagentoAPIVersion' => Mage::getVersion(), 'MagentoStoreList' => 'stores', 'MagentoURL' => $mode, 'MagentoUserName' => 'api_user_name', 'MagentoUserPwd' => $apiPassword, 'MageStatus1' =>'processing_status', 'MageStatus2' => 'error_status', 'MageStatus3' => 'sentto_warehouse_status', 'MageVendorCode' => 'supplier_attribute');
81
+ $temproray = array();
82
+
83
+
84
+ foreach ($columns as $key => $val) {
85
+ if($key == 'MagentoAPIVersion' || $key == 'MagentoUserPwd')
86
+ {
87
+ $temproray[] = array($fieldsetData['logicbroker_company_id'], $key, $val);
88
+ }elseif($key == 'MagentoURL'){
89
+ $url = $fieldsetData[$val];
90
+ //$append = (preg_match("/\/\z/i",$fieldsetData[$val]))?'index.php/v2_soap/index':'/index.php/v2_soap/index';
91
+ $slash = (preg_match("/\/\z/i",$fieldsetData[$val]))?'':'/';
92
+ $append = (preg_match("/v2_soap/i",$fieldsetData[$val]))?'':$slash.'index.php/v2_soap/index';
93
+ $temproray[] = array($fieldsetData['logicbroker_company_id'], $key,$url.$append);
94
+ }elseif($key == 'MagentoStoreList'){
95
+ $temproray[] = array($fieldsetData['logicbroker_company_id'], $key, implode(',',$fieldsetData[$val]));
96
+ }
97
+ else{
98
+ $temproray[] = array($fieldsetData['logicbroker_company_id'], $key, $fieldsetData[$val]);
99
+ }
100
+ }
101
+ //print_r($temproray);
102
+ //die();
103
+ foreach ($temproray as $values) {
104
+ $row = array();
105
+ foreach ($values as $val) {
106
+ $row[] = $val;
107
+ }
108
+ $data = $parser->getRowXml($row);
109
+ $adapter->streamWrite($data);
110
+ array_merge($row, $data);
111
+ }
112
+ }
113
+
114
+
115
+ protected function _getExportHeadersSupplier()
116
+ {
117
+ $headers = array();
118
+
119
+
120
+ foreach ($this->prepareExportCollection() as $keys => $values) {
121
+
122
+ foreach($values as $key=>$val)
123
+ if(!in_array($key,$headers))
124
+ $headers[] = $key;
125
+
126
+ }
127
+
128
+ return $headers;
129
+ }
130
+
131
+ protected function _getExportRowsSupplier($adapter,$parser)
132
+ {
133
+ foreach ($this->prepareExportCollection() as $keys => $values) {
134
+ $row = array();
135
+ foreach ($values as $val) {
136
+ $row[] = $val;
137
+ }
138
+ $data = $parser->getRowXml($row);
139
+ $adapter->streamWrite($data);
140
+ array_merge($row,$data);
141
+ }
142
+
143
+ }
144
+
145
+
146
+
147
+
148
+ /**
149
+ * Retrieve a file container array by grid data as MS Excel 2003 XML Document
150
+ *
151
+ * Return array with keys type and value
152
+ *
153
+ * @return string
154
+ */
155
+ public function getExcelFile($fieldsetData)
156
+ {
157
+ $sheetName =array('configurationproperties','systemvendor');
158
+ if(!is_array($fieldsetData))
159
+ {
160
+ return false;
161
+ }
162
+ if($this->prepareExportCollection() > 0)
163
+ {
164
+
165
+ $parser = new Varien_Convert_Parser_Xml_Excel();
166
+ $io = new Varien_Io_File();
167
+
168
+ $path = Mage::getBaseDir('var') . DS . 'export' . DS;
169
+ $name = 'logicbroker_integration_'.date('YmdHis');
170
+ $file = $path . DS . $name . '.xml';
171
+
172
+ $io->setAllowCreateFolders(true);
173
+ $io->open(array('path' => $path));
174
+ $io->streamOpen($file, 'w+');
175
+ $io->streamLock(true);
176
+ $io->streamWrite($parser->getHeaderXml($sheetName[0]));
177
+ $io->streamWrite($parser->getRowXml($this->_getExportHeadersConfiguration($fieldsetData)));
178
+ $this->_getExportRowsConfiguration($io,$parser,$fieldsetData);
179
+ $io->streamWrite('</Table></Worksheet>');
180
+ $io->streamWrite('<Worksheet ss:Name="'.$sheetName[1].'"><Table>');
181
+ $io->streamWrite($parser->getRowXml($this->_getExportHeadersSupplier()));
182
+ $this->_getExportRowsSupplier($io,$parser);
183
+ $io->streamWrite($parser->getFooterXml());
184
+ $io->streamUnlock();
185
+ $io->streamClose();
186
+
187
+ return array(
188
+ 'type' => 'filename',
189
+ 'value' => $file,
190
+ 'rm' => true // can delete file after use
191
+ );
192
+ }else{
193
+ return false;
194
+ }
195
+
196
+
197
+ }
198
+
199
+
200
+
201
+ }
202
+
includes/src/Logicbroker_Fulfillment_Model_Infromlogicbroker.php ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ * To change this template, choose Tools | Templates
4
+ * and open the template in the editor.
5
+ */
6
+
7
+ /**
8
+ * Description of Infromlogicbroker
9
+ *
10
+ * @author shubhs
11
+ */
12
+ class Infromlogicbroker {
13
+ //put your code here
14
+ }
15
+ ?>
includes/src/Logicbroker_Fulfillment_Model_Logicbroker.php ADDED
@@ -0,0 +1,367 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Logicbroker
5
+ *
6
+ * @category Community
7
+ * @package Logicbroker_Fulfillment
8
+ */
9
+
10
+ class Logicbroker_Fulfillment_Model_Logicbroker {
11
+ /* Validate the user inputs */
12
+
13
+ public function validation($request) {
14
+ $result = array();
15
+ if (!is_array($request)) {
16
+ return $result[] = array('error' => 'Something wrong with request');
17
+ }
18
+
19
+ if (!$this->_checkRequestParams($request)) {
20
+ return $result[] = array('error' => 'Please fill all field mark with astrik sign');
21
+ }
22
+
23
+ if (!$this->_checkAttribute($request)) {
24
+ $value = $request['supplier_attribute'];
25
+ return $result[] = array('error' => 'Vendor attribute code "' . $value['value'] . '" is not defined');
26
+ }
27
+ if (!$this->checkAtLeastOneSupplier()) {
28
+ return $result[] = array('error' => 'At least one vendor information available to share with logicbroker');
29
+ }
30
+ if(Mage::app()->getRequest()->getParam('savelater'))
31
+ {
32
+ //no further processing only fields are saving in magento database
33
+ return $result[] = array('success' => 'Data has been validate successfully.... ');
34
+ }
35
+ return $result[] = array('success' => 'Please wait while transmitting your configuration to logicbroker');
36
+
37
+
38
+ }
39
+
40
+ public function checkAtLeastOneSupplier() {
41
+ $logicbrokerCollection = Mage::getModel('logicbroker/supplier')->getCollection();
42
+ //->addFieldToFilter(array('is_update', 'verified'), array('1', '0'))
43
+ //->addFieldToSelect(array('company_id', 'magento_vendor_code'));
44
+
45
+ //return $logicbrokerCollection->getSelect()->__toString();
46
+ $comapnyIdArray = $logicbrokerCollection->getData();
47
+ if (count($comapnyIdArray) > 0) {
48
+ return true;
49
+ } else {
50
+ return false;
51
+ }
52
+ }
53
+
54
+ /* check that all listed field will not be empty in integration form
55
+ * username
56
+ * password
57
+ * production Url >> regx check
58
+ * staging Url >> regx check
59
+ * Api username >> regx check only alpha
60
+ * supplier Attribute
61
+ *
62
+ */
63
+
64
+ protected function _checkRequestParams($request) {
65
+ $values = array('logic_broker_username', 'logic_broker_password', 'your_production_store_url', 'your_staging_store_url', 'api_user_name', 'supplier_attribute');
66
+
67
+ foreach ($request as $key => $val) {
68
+ if (in_array($key, $values) && $val['value'] == '') {
69
+
70
+ return false;
71
+ }
72
+ }
73
+ return true;
74
+ }
75
+
76
+ protected function _checkAttribute($request) {
77
+ $supplierAttributeCode = $request['supplier_attribute'];
78
+ $attributeDetails = Mage::getSingleton("eav/config")->getAttribute("catalog_product", $supplierAttributeCode['value']);
79
+
80
+ if ($attributeDetails->getId() && $attributeDetails->getFrontendInput() == 'select') {
81
+ return true;
82
+ } else {
83
+ return false;
84
+ }
85
+ }
86
+
87
+ public function checkProductionMode($request) {
88
+ if (!is_array($request)) {
89
+ return false;
90
+ }
91
+ $salseOderItemTable = Mage::getSingleton('core/resource')->getTableName('sales/order_item');
92
+ $orders = Mage::getResourceModel('sales/order_collection')->addAttributeTofilter('status', 'complete');
93
+ $orders->getSelect()->join(array('item' => $salseOderItemTable), 'item.order_id = main_table.entity_id and item.product_type = "simple"', array('item.sku'));
94
+ $productCollection = Mage::getResourceModel('catalog/product_collection');
95
+ $skus = array();
96
+ foreach ($orders as $order) {
97
+ $skus[] = $order->getSku();
98
+ }
99
+
100
+
101
+ $productCollection->addAttributeToFilter('sku', array('in' => $skus))->addAttributeToFilter(trim($request['supplier_attribute']), array('notnull' => true));
102
+ if (count($productCollection) > 0) {
103
+ return 'production';
104
+ } else {
105
+ return 'qa';
106
+ }
107
+ }
108
+
109
+ public function installConfig($fieldsetData) {
110
+ if (!$this->createApiRoleAndUser($fieldsetData)) {
111
+ Mage::throwException('Problem in creating API role and user');
112
+ }
113
+
114
+ if (!$this->attributeOptionValidation($fieldsetData)) {
115
+ Mage::throwException('Problem in validating attribute options');
116
+ }
117
+
118
+ if (!$this->checkAndCreateOrderStatus($fieldsetData)) {
119
+ Mage::throwException('Problem in validating order status');
120
+ }
121
+ return true;
122
+ }
123
+
124
+ /* Creae API role */
125
+
126
+ public function createApiRoleAndUser($fieldsetData) {
127
+
128
+ $role = Mage::getModel('api/roles');
129
+ $roleName = 'logicbroker';
130
+ $parentId = '';
131
+ $roleType = 'G';
132
+ $ruleAsString = Mage::helper('logicbroker')->getConfigObject('apiconfig/rolepermission/data');
133
+ $ruleNodes = array();
134
+
135
+ if (!is_array($fieldsetData)) {
136
+ return false;
137
+ }
138
+ foreach (explode(',', $ruleAsString) as $rules) {
139
+ $ruleNodes[] = trim($rules);
140
+ }
141
+ $role->load($roleName, 'role_name');
142
+
143
+ try {
144
+ $role = $role->setName($roleName)
145
+ ->setPid($parentId)
146
+ ->setRoleType($roleType)
147
+ ->save();
148
+
149
+ Mage::getModel("api/rules")->setRoleId($role->getId())
150
+ ->setResources($ruleNodes)
151
+ ->saveRel();
152
+ } catch (Exception $e) {
153
+ return false; //$e->getMessage();
154
+ }
155
+ //$password = Mage::helper('core')->decrypt(Mage::getStoreConfig('logicbroker_integration/integration/api_password'));
156
+ $password = $fieldsetData['api_password'];
157
+ $userExist = $this->_userExists($fieldsetData['api_user_name'],$fieldsetData['email']);
158
+ $userId = '';
159
+ if (is_array($userExist)) {
160
+ $modelData = Mage::getModel('api/user')->load($userExist[1]);
161
+ $userId = $modelData->getUserId();
162
+ }else
163
+ {
164
+ $modelData = Mage::getModel('api/user');
165
+ }
166
+
167
+ $modelData->setData(array(
168
+ 'user_id'=> $userId,
169
+ 'username' => $fieldsetData['api_user_name'],
170
+ 'firstname' => $fieldsetData['firstname'],
171
+ 'lastname' => $fieldsetData['lastname'],
172
+ 'email' => $fieldsetData['email'],
173
+ 'api_key' => $password,
174
+ 'api_key_confirmation' => $password,
175
+ 'is_active' => 1,
176
+ 'user_roles' => '',
177
+ 'assigned_user_role' => '',
178
+ 'role_name' => '',
179
+ 'roles' => array($role->getId()) // your created custom role
180
+ ));
181
+
182
+ try {
183
+
184
+ Mage::register('api_password', $modelData->getApiKey());
185
+ $modelData->save();
186
+ $modelData->setRoleIds(array($role->getId())) // your created custom role
187
+ ->setRoleUserId($modelData->getUserId())
188
+ ->saveRelations();
189
+ }
190
+
191
+ catch (Exception $e) {
192
+ return false;//$e->getMessage();
193
+ }
194
+ return true;
195
+ }
196
+
197
+ protected function _userExists($username,$email)
198
+ {
199
+ $resource = Mage::getSingleton('core/resource');
200
+ $usersTable = $resource->getTableName('api/user');
201
+ $adapter = $resource->getConnection('core_read');
202
+ $condition = array(
203
+ $adapter->quoteInto("{$usersTable}.username = ?", $username),
204
+ $adapter->quoteInto("{$usersTable}.email = ?", $email),
205
+ );
206
+ $select = $adapter->select()
207
+ ->from($usersTable)
208
+ ->where(implode(' OR ', $condition))
209
+ ->where($usersTable.'.user_id != ?', '');
210
+ $result = $adapter->fetchRow($select);
211
+ if(is_array($result) && count($result) > 0 )
212
+ {
213
+ return array(true,(int)$result['user_id']);
214
+ }else
215
+ {
216
+ return false;
217
+ }
218
+
219
+ }
220
+
221
+ protected function _generatePassword($length = 8) {
222
+ $chars = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789';
223
+ $count = mb_strlen($chars);
224
+
225
+ for ($i = 0, $result = ''; $i < $length; $i++) {
226
+ $index = rand(0, $count - 1);
227
+ $result .= mb_substr($chars, $index, 1);
228
+ }
229
+
230
+ return $result;
231
+ }
232
+
233
+ /* Creae Atrribute option if not available */
234
+
235
+ public function attributeOptionValidation($fieldsetData) {
236
+ if (!is_array($fieldsetData)) {
237
+ return false;
238
+ }
239
+
240
+ $logicbrokerCollection = Mage::getModel('logicbroker/supplier')->getCollection()
241
+ ->addFieldToFilter(array('is_update', 'verified'), array('1', '0',''))->addFieldToFilter('status','')
242
+ ->addFieldToSelect(array('company_id', 'magento_vendor_code'));
243
+
244
+ //return $logicbrokerCollection->getSelect()->__toString();
245
+ $comapnyIds = $logicbrokerCollection->getData();
246
+ if (count($comapnyIds) > 0) {
247
+ foreach ($comapnyIds as $key => $value) {
248
+ if (!$this->_checkAndCreateOptions($value['magento_vendor_code'],$fieldsetData['supplier_attribute'])) {
249
+ return false;
250
+ }
251
+ }
252
+ }
253
+ return true;
254
+ }
255
+
256
+ protected function _checkAndCreateOptions($value, $fieldsetData) {
257
+
258
+ $attributeLables = array();
259
+ $optionToBeSearch = strtolower($value);
260
+ $attributeCode = strtolower($fieldsetData);
261
+
262
+ $attributeDetails = Mage::getSingleton("eav/config")->getAttribute("catalog_product", $attributeCode);
263
+ $options = $attributeDetails->getSource()->getAllOptions(false);
264
+ Foreach ($options as $option) {
265
+
266
+ $attributeLables[] = strtolower($option["label"]);
267
+ }
268
+
269
+ if (!in_array($optionToBeSearch, $attributeLables)) {
270
+ $installer = new Mage_Eav_Model_Entity_Setup('core_setup');
271
+ $installer->startSetup();
272
+ try {
273
+ $searchAttributeOptions = array($optionToBeSearch);
274
+ $productEntityTypeId = Mage::getModel('catalog/product')->getResource()->getTypeId();
275
+ $createOptions = array();
276
+ $createOptions['attribute_id'] = $installer->getAttributeId($productEntityTypeId, $attributeCode);
277
+
278
+ for ($iCount = 0; $iCount < sizeof($searchAttributeOptions); $iCount++) {
279
+ $createOptions['value']['option' . $iCount][0] = $searchAttributeOptions[$iCount];
280
+ }
281
+ $installer->addAttributeOption($createOptions);
282
+ } catch (Exception $e) {
283
+ return false; //$e->getMessage();
284
+ }
285
+
286
+ $installer->endSetup();
287
+ }
288
+ return true;
289
+ }
290
+
291
+ public function checkAndCreateOrderStatus($fieldsetData) {
292
+ if (!is_array($fieldsetData) && empty($fieldsetData)) {
293
+ return false;
294
+ }
295
+ $statuses = $this->_getStatusCode($fieldsetData);
296
+ $state = 'processing';
297
+ $isDefault = '0';
298
+ foreach ($statuses as $status => $label) {
299
+ $statusModel = Mage::getModel('sales/order_status')->load($status);
300
+ if (!$statusModel->getStatus()) {
301
+ $statusModel->setData(array('status' => $status, 'label' => $label))->setStatus($status);
302
+ try {
303
+ $statusModel->save();
304
+ $statusModel->assignState($state, $isDefault);
305
+
306
+ }catch (Mage_Core_Exception $e) {
307
+ return false; //$e->getMessage();
308
+ }
309
+ }
310
+ }
311
+ return true;
312
+ }
313
+
314
+ protected function _getStatusCode($fieldsetData)
315
+ {
316
+ $status = array($fieldsetData['processing_status'],$fieldsetData['error_status'],$fieldsetData['sentto_warehouse_status']);
317
+ $labels = array();
318
+ foreach($status as $label)
319
+ {
320
+ $labels[$label] = ucwords(str_replace('_',' ', $label));
321
+ }
322
+ return $labels;
323
+ }
324
+
325
+
326
+ public function updateSupplier()
327
+ {
328
+
329
+ $logicbrokerCollection = Mage::getModel('logicbroker/supplier')->getCollection()
330
+ ->addFieldToFilter(array('is_update', 'verified'), array('1', '0'))
331
+ ->addFieldToSelect(array('company_id', 'vendor_id'));
332
+
333
+ foreach($logicbrokerCollection->getData() as $key=>$value)
334
+ {
335
+ $modelSupplier = Mage::getModel('logicbroker/supplier')->load($value['vendor_id']);
336
+ $modelSupplier->setIsUpdate('0');
337
+ $modelSupplier->setVerified('1');
338
+ try
339
+ {
340
+ $modelSupplier->save();
341
+ }catch(Exception $e)
342
+ {
343
+ return false;
344
+ }
345
+ }
346
+
347
+
348
+ }
349
+
350
+
351
+ public function createOptionValueOnSave($value)
352
+ {
353
+
354
+ $integration = Mage::getStoreConfig('logicbroker_integration/integration/supplier_attribute');
355
+ if($integration != null && $integration && $value)
356
+ {
357
+
358
+ $this->_checkAndCreateOptions($value,$integration);
359
+
360
+ }
361
+ return;
362
+ }
363
+
364
+
365
+ }
366
+
367
+ ?>
includes/src/Logicbroker_Fulfillment_Model_Observer.php ADDED
@@ -0,0 +1,47 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Logicbroker
5
+ *
6
+ * @category Community
7
+ * @package Logicbroker_Fulfillment
8
+ */
9
+
10
+ class Logicbroker_Fulfillment_Model_Observer
11
+ {
12
+ public function connectToLogicbroker($object)
13
+ {
14
+
15
+ $modelSupplier = Mage::getModel('logicbroker/supplier');
16
+ $modelLogicbroker = Mage::getModel('logicbroker/logicbroker');
17
+ $modelSync = Mage::getModel('logicbroker/synchronize');
18
+ $modelEmail = Mage::getModel('logicbroker/email');
19
+ $groupData = $object->getobject()->getGroups();
20
+
21
+
22
+
23
+
24
+
25
+ foreach($groupData as $group=>$groupDataArray )
26
+ $fieldsetData = array();
27
+ foreach ($groupDataArray['fields'] as $field => $fieldData) {
28
+ $fieldsetData[$field] = (is_array($fieldData) && isset($fieldData['value'])) ? $fieldData['value'] : null;
29
+ }
30
+ $modelLogicbroker->installConfig($fieldsetData);
31
+ if(Mage::app()->getRequest()->getParam('savelater'))
32
+ {
33
+ //no further processing only fields are saving in magento database
34
+ return;
35
+ }
36
+ $modelSync->process($fieldsetData);
37
+ $modelLogicbroker->updateSupplier();
38
+ if(!Mage::getStoreConfig('logicbroker_integration/integration/notificationstatus'))
39
+ $modelEmail->send(null,$fieldsetData);
40
+
41
+
42
+ }
43
+
44
+
45
+ }
46
+
47
+ ?>
includes/src/Logicbroker_Fulfillment_Model_Resource_Supplier.php ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Logicbroker
5
+ *
6
+ * @category Community
7
+ * @package Logicbroker_Fulfillment
8
+ */
9
+
10
+ class Logicbroker_Fulfillment_Model_Resource_Supplier extends Mage_Core_Model_Mysql4_Abstract
11
+ {
12
+ protected function _construct()
13
+ {
14
+ $this->_init("logicbroker/supplier", "vendor_id");
15
+ }
16
+ }
includes/src/Logicbroker_Fulfillment_Model_Resource_Supplier_Collection.php ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Logicbroker
5
+ *
6
+ * @category Community
7
+ * @package Logicbroker_Fulfillment
8
+ */
9
+
10
+ class Logicbroker_Fulfillment_Model_Resource_Supplier_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract
11
+ {
12
+
13
+ public function _construct(){
14
+ $this->_init("logicbroker/supplier");
15
+ }
16
+
17
+
18
+
19
+ }
20
+
includes/src/Logicbroker_Fulfillment_Model_Supplier.php ADDED
@@ -0,0 +1,126 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Logicbroker
5
+ *
6
+ * @category Community
7
+ * @package Logicbroker_Fulfillment
8
+ */
9
+
10
+ class Logicbroker_Fulfillment_Model_Supplier extends Mage_Core_Model_Abstract
11
+ {
12
+ protected function _construct(){
13
+
14
+ $this->_init("logicbroker/supplier");
15
+ }
16
+
17
+ public function getCompanyids() {
18
+ $collection = Mage::getModel('logicbroker/supplier')->getCollection();
19
+ $collection = Mage::getModel('logicbroker/supplier')
20
+ ->getCollection()
21
+ ->addFieldToSelect('company_id');
22
+ $data = $collection->getData();
23
+ $options = array();
24
+ foreach($data as $newdata) {
25
+ if(!empty($newdata['company_id'])) {
26
+ $options[] = $newdata['company_id'];
27
+ }
28
+ }
29
+ return $options;
30
+ }
31
+
32
+ public function getCountry() {
33
+ $countries = Mage::getModel('adminhtml/system_config_source_country')->toOptionArray();
34
+ $options = array();
35
+ foreach ($countries as $country) {
36
+ if(!empty($country['value'])) {
37
+ $options[$country['value']] = $country['label'];
38
+ }
39
+ }
40
+ return $options;
41
+ }
42
+
43
+ public function validateCompany($companyid,$supplierId) {
44
+ $flag = 0;
45
+ if(empty($companyid) || empty($supplierId))
46
+ {
47
+ return $flag;
48
+ }
49
+ $collection = Mage::getModel('logicbroker/supplier')
50
+ ->getCollection()
51
+ ->addFieldToFilter('company_id', $companyid)
52
+ ->addFieldToFilter('status',array('neq'=>'deleted'))
53
+ ->addFieldToSelect('company_id')
54
+ ->addFieldToSelect('vendor_id');
55
+ $data = $collection->getData();
56
+ if(array_key_exists(0,$data) and $data[0]['company_id'] != null) {
57
+ if($data[0]['vendor_id'] != $supplierId) {
58
+ return $flag = 1;
59
+ }else
60
+ {
61
+ return $flag;
62
+ }
63
+ }
64
+
65
+ }
66
+
67
+ public function getVendorAttributeId()
68
+ {
69
+ $attributeCode = Mage::getStoreConfig('logicbroker_integration/integration/supplier_attribute');
70
+ //$attribute = Mage::getModel('eav/config')->getAttribute('catalog_product',$attributeCode);
71
+ if($attributeCode != null)
72
+ {
73
+ return $attributeCode;
74
+ }else
75
+ {
76
+ return '';
77
+ }
78
+
79
+
80
+ }
81
+
82
+ public function deleteOption($attributeCode,$optionvalue) {
83
+ //$attributeCode = Mage::getStoreConfig('logicbroker_integration/integration/supplier_attribute');
84
+ if ($attributeCode) {
85
+
86
+ $attribute = Mage::getModel('eav/config')->getAttribute('catalog_product', $attributeCode);
87
+ $collection = Mage::getResourceModel('eav/entity_attribute_option_collection')
88
+ ->setAttributeFilter($attribute->getId())
89
+ ->setStoreFilter($attribute->getStoreId())
90
+ ->load();
91
+ //echo '<pre>';
92
+ //die(print_r($collection->getData()));
93
+ foreach ($collection as $option) {
94
+ if($option['option_id'] == $optionvalue)
95
+ $option->delete();
96
+ }
97
+ } else {
98
+ return ;
99
+ }
100
+ }
101
+ //check if information is submitted to logicbroker
102
+ public function isVendorSubmitted()
103
+ {
104
+ $objId = Mage::app()->getRequest()->getParam('vendor_id');
105
+ if(!empty($objId)){
106
+ $logicbrokerCollection = $this->getCollection()
107
+ ->addFieldToFilter(array('is_update', 'verified'), array('1', '0'))
108
+ ->addFieldToFilter('status','')
109
+ // ->addFieldToFilter('vendor_id',$objId)
110
+ ->addFieldToSelect(array('company_id', 'magento_vendor_code'));
111
+
112
+ //return $logicbrokerCollection->getSelect()->__toString();
113
+ $comapnyIdArray = $logicbrokerCollection->getData();
114
+ if (count($comapnyIdArray) > 0) {
115
+ return true;
116
+ } else {
117
+ return false;
118
+ }
119
+ }else
120
+ {
121
+ return false;
122
+ }
123
+
124
+ }
125
+ }
126
+
includes/src/Logicbroker_Fulfillment_Model_Synchronize.php ADDED
@@ -0,0 +1,45 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+
4
+ /**
5
+ * Description of Createexcelxml
6
+ *
7
+ * @author shubhs
8
+ */
9
+
10
+ class Logicbroker_Fulfillment_Model_Synchronize {
11
+
12
+ protected $_modelResource = 'logicbroker';
13
+ protected $_configNode = 'apiconfig/connectiontype/type';
14
+
15
+
16
+ public function process($fieldsetData)
17
+ {
18
+ $model = $this->_getModelObject();
19
+ try
20
+ {
21
+ $fileAttachment = $model->prepareData($fieldsetData);
22
+ if(!$model->send($fileAttachment,$fieldsetData))
23
+ {
24
+ Mage::throwException('Problem in sending attachment mail');
25
+ }
26
+
27
+ }catch(Exception $e)
28
+ {
29
+ return false;
30
+ }
31
+ }
32
+
33
+ protected function _getModelObject()
34
+ {
35
+ $modelClass = $this->_modelResource;
36
+ $type = Mage::helper('logicbroker')->getConfigObject($this->_configNode);
37
+
38
+ //die($modelClass.'/'.$type);
39
+ return Mage::getModel($modelClass.'/'.$type);
40
+ }
41
+
42
+
43
+ }
44
+
45
+ ?>
includes/src/Logicbroker_Fulfillment_Model_System_Config_Source_Attributecodes.php ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /*
4
+ * To change this template, choose Tools | Templates
5
+ * and open the template in the editor.
6
+ */
7
+
8
+ /**
9
+ * Description of Attributecode
10
+ *
11
+ * @author shubhs
12
+ */
13
+
14
+ class Logicbroker_Fulfillment_Model_System_Config_Source_Attributecodes {
15
+
16
+ public function toOptionArray() {
17
+ $attributes = Mage::getResourceModel('catalog/product_attribute_collection')
18
+ ->getItems();
19
+ $attributeCode = array();
20
+ foreach ($attributes as $attribute) {
21
+
22
+ if ($attribute->getFrontendInput() == 'select' && $attribute->getIsUserDefined()) {
23
+ $attributeCode[] = array('value' => $attribute->getAttributecode(), 'label' => Mage::helper('logicbroker')->__($attribute->getFrontendLabel()));
24
+ }
25
+ }
26
+ array_unshift($attributeCode,array('value' => '', 'label' => Mage::helper('logicbroker')->__('--Please Select--')));
27
+ return $attributeCode;
28
+ }
29
+ }
30
+
31
+
includes/src/Logicbroker_Fulfillment_Model_System_Config_Source_Ediqualifier.php ADDED
@@ -0,0 +1,70 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /*
4
+ * To change this template, choose Tools | Templates
5
+ * and open the template in the editor.
6
+ */
7
+
8
+ /**
9
+ * Description of Ediidentifier
10
+ *
11
+ * @author shubhs
12
+ */
13
+ class Logicbroker_Fulfillment_Model_System_Config_Source_Ediqualifier {
14
+
15
+
16
+ public function toOptionArray()
17
+ {
18
+ return array(
19
+ array('value' => '', 'label' => Mage::helper('logicbroker')->__('--Please Select--')),
20
+ array('value' => Mage::helper('logicbroker')->__('01 Duns (Dun & Bradstreet)'), 'label' => Mage::helper('logicbroker')->__('01 Duns (Dun & Bradstreet)')),
21
+ array('value' => Mage::helper('logicbroker')->__('02 SCAC (Standard Carrier Alpha Code)'), 'label' => Mage::helper('logicbroker')->__('02 SCAC (Standard Carrier Alpha Code)')),
22
+ array('value' => Mage::helper('logicbroker')->__('03 FMC (Federal Maritime Commission)'), 'label' => Mage::helper('logicbroker')->__('03 FMC (Federal Maritime Commission)')),
23
+ array('value' => Mage::helper('logicbroker')->__('04 IATA (International Air Transport Association)'), 'label' => Mage::helper('logicbroker')->__('04 IATA (International Air Transport Association)')),
24
+ array('value' => Mage::helper('logicbroker')->__('08 UCC EDI Communications ID (Comm ID)'), 'label' => Mage::helper('logicbroker')->__('08 UCC EDI Communications ID (Comm ID)')),
25
+ array('value' => Mage::helper('logicbroker')->__('09 X.121 (CCITT)'), 'label' => Mage::helper('logicbroker')->__('09 X.121 (CCITT)')),
26
+ array('value' => Mage::helper('logicbroker')->__('10 Department of Defence (DoD) Activity Address Code'), 'label' => Mage::helper('logicbroker')->__('10 Department of Defence (DoD) Activity Address Code')),
27
+ array('value' => Mage::helper('logicbroker')->__('11 DEA (Drug Enforcement Administration)'), 'label' => Mage::helper('logicbroker')->__('11 DEA (Drug Enforcement Administration)')),
28
+ array('value' => Mage::helper('logicbroker')->__('12 Phone (Telephone Companies)'), 'label' => Mage::helper('logicbroker')->__('12 Phone (Telephone Companies)')),
29
+ array('value' => Mage::helper('logicbroker')->__('13 UCS Code (UCS Code is a Code is Used for UCS Transmissions, it includes the Area Code and Telephone Number of Modem, it Does Not Include Punctuation, Blanks or Access Code )'), 'label' => Mage::helper('logicbroker')->__('13 UCS Code (UCS Code is a Code is Used for UCS Transmissions, it includes the Area Code and Telephone Number of Modem, it Does Not Include Punctuation, Blanks or Access Code )')),
30
+ array('value' => Mage::helper('logicbroker')->__('14 Duns Plus Suffix'), 'label' => Mage::helper('logicbroker')->__('14 Duns Plus Suffix')),
31
+ array('value' => Mage::helper('logicbroker')->__('15 Petroleum Accountants Society Of Canada Company Code'), 'label' => Mage::helper('logicbroker')->__('15 Petroleum Accountants Society Of Canada Company Code')),
32
+ array('value' => Mage::helper('logicbroker')->__('16 Duns Number With 4-Character Suffix'), 'label' => Mage::helper('logicbroker')->__('16 Duns Number With 4-Character Suffix')),
33
+ array('value' => Mage::helper('logicbroker')->__('17 American Bankers Association (ABA) Transit Routing Number (Including check digit, 9-digit )'), 'label' => Mage::helper('logicbroker')->__('17 American Bankers Association (ABA) Transit Routing Number (Including check digit, 9-digit )')),
34
+ array('value' => Mage::helper('logicbroker')->__('18 Association of American Railroads (AAR) Standard Distribution Code'), 'label' => Mage::helper('logicbroker')->__('18 Association of American Railroads (AAR) Standard Distribution Code')),
35
+ array('value' => Mage::helper('logicbroker')->__('19 EDI Council of Australia (EDICA) Communications ID Number (COMM ID)'), 'label' => Mage::helper('logicbroker')->__('19 EDI Council of Australia (EDICA) Communications ID Number (COMM ID)')),
36
+ array('value' => Mage::helper('logicbroker')->__('20 Health Industry Number (HIN)'), 'label' => Mage::helper('logicbroker')->__('20 Health Industry Number (HIN)')),
37
+ array('value' => Mage::helper('logicbroker')->__('21 Integrated Postsecondary Education Data system, or (IPEDS)'), 'label' => Mage::helper('logicbroker')->__('21 Integrated Postsecondary Education Data system, or (IPEDS)')),
38
+ array('value' => Mage::helper('logicbroker')->__('22 Federal Interagency Commision on Education, or FICE'), 'label' => Mage::helper('logicbroker')->__('22 Federal Interagency Commision on Education, or FICE')),
39
+ array('value' => Mage::helper('logicbroker')->__('23 National Center for Education Statistics Common Core Of Data 12-Digit Number For Pre-K-Grade 12 Institutes, or NCES'), 'label' => Mage::helper('logicbroker')->__('23 National Center for Education Statistics Common Core Of Data 12-Digit Number For Pre-K-Grade 12 Institutes, or NCES')),
40
+ array('value' => Mage::helper('logicbroker')->__('24 The College Board`s Admission Testing Program 4-Digit Code Of Postsecondary Institutes, or ATP'), 'label' => Mage::helper('logicbroker')->__('24 The College Board`s Admission Testing Program 4-Digit Code Of Postsecondary Institutes, or ATP')),
41
+ array('value' => Mage::helper('logicbroker')->__('25 American College Testing Program 4-Digit code Of Postsecondary Institutions, or ACT'), 'label' => Mage::helper('logicbroker')->__('25 American College Testing Program 4-Digit code Of Postsecondary Institutions, or ACT')),
42
+ array('value' => Mage::helper('logicbroker')->__('26 Statistics of Canada List Of Postsecondary Institutions'), 'label' => Mage::helper('logicbroker')->__('26 Statistics of Canada List Of Postsecondary Institutions')),
43
+ array('value' => Mage::helper('logicbroker')->__('27 Carrier Identification Number as assigned by Health Care Financing Administration (HCFA)'), 'label' => Mage::helper('logicbroker')->__('27 Carrier Identification Number as assigned by Health Care Financing Administration (HCFA)')),
44
+ array('value' => Mage::helper('logicbroker')->__('28 Fiscal Intermediary Identification Number as assigned by Health Care Financing Administration (HCFA)'), 'label' => Mage::helper('logicbroker')->__('28 Fiscal Intermediary Identification Number as assigned by Health Care Financing Administration (HCFA)')),
45
+ array('value' => Mage::helper('logicbroker')->__('29 Medicare Provider and Supplier Identification Number as assigned by Health Care Financing Administration (HCFA)'), 'label' => Mage::helper('logicbroker')->__('29 Medicare Provider and Supplier Identification Number as assigned by Health Care Financing Administration (HCFA)')),
46
+ array('value' => Mage::helper('logicbroker')->__('30 U.S. Federal Tax Identification Number'), 'label' => Mage::helper('logicbroker')->__('30 U.S. Federal Tax Identification Number')),
47
+ array('value' => Mage::helper('logicbroker')->__('31 Jurisdiction Identification Number Plus 4 as assigned by the International Association Of Industrial Accident Boards and Commissions (IAIABC)'), 'label' => Mage::helper('logicbroker')->__('31 Jurisdiction Identification Number Plus 4 as assigned by the International Association Of Industrial Accident Boards and Commissions (IAIABC)')),
48
+ array('value' => Mage::helper('logicbroker')->__('32 U.S. Federal Employer Identification Number (FEIN)'), 'label' => Mage::helper('logicbroker')->__('32 U.S. Federal Employer Identification Number (FEIN)')),
49
+ array('value' => Mage::helper('logicbroker')->__('33 National Association Of Insurance Commissioners Company Code (NAIC)'), 'label' => Mage::helper('logicbroker')->__('33 National Association Of Insurance Commissioners Company Code (NAIC)')),
50
+ array('value' => Mage::helper('logicbroker')->__('34 Medicaid Provider and Supplier Identification Number as assigned by individual State Medicaid Agencies in conjunction with Health Care Financing Administration (HCFA)'), 'label' => Mage::helper('logicbroker')->__('34 Medicaid Provider and Supplier Identification Number as assigned by individual State Medicaid Agencies in Conjunction with Health Care Financing Administration (HCFA)')),
51
+ array('value' => Mage::helper('logicbroker')->__('35 Statistics Canada Canadian College Student Information System Institution Codes'), 'label' => Mage::helper('logicbroker')->__('35 Statistics Canada Canadian College Student Information System Institution Codes')),
52
+ array('value' => Mage::helper('logicbroker')->__('36 Statistics Canada University Student Information System Institution codes'), 'label' => Mage::helper('logicbroker')->__('36 Statistics Canada University Student Information System Institution codes')),
53
+ array('value' => Mage::helper('logicbroker')->__('37 Society of Property Information Compilers and Analysts'), 'label' => Mage::helper('logicbroker')->__('37 Society of Property Information Compilers and Analysts')),
54
+ array('value' => Mage::helper('logicbroker')->__('AM Association Mexicana del Codigo de Producto (AMECOP) Communication ID'), 'label' => Mage::helper('logicbroker')->__('AM Association Mexicana del Codigo de Producto (AMECOP) Communication ID')),
55
+ array('value' => Mage::helper('logicbroker')->__('NR National Retail Merchants Association (NRMA) - Assigned'), 'label' => Mage::helper('logicbroker')->__('NR National Retail Merchants Association (NRMA) - Assigned')),
56
+ array('value' => Mage::helper('logicbroker')->__('SN Standard Address Number'), 'label' => Mage::helper('logicbroker')->__('SN Standard Address Number')),
57
+ array('value' => Mage::helper('logicbroker')->__('ZZ Mutually Defined'), 'label' => Mage::helper('logicbroker')->__('ZZ Mutually Defined')),
58
+ );
59
+ }
60
+
61
+ public function toArray()
62
+ {
63
+ return array(
64
+ 0 => Mage::helper('adminhtml')->__('No'),
65
+ 1 => Mage::helper('adminhtml')->__('Yes'),
66
+ );
67
+ }
68
+ }
69
+
70
+ ?>
includes/src/Logicbroker_Fulfillment_Model_System_Config_Source_Optionvalues.php ADDED
@@ -0,0 +1,66 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /*
4
+ * To change this template, choose Tools | Templates
5
+ * and open the template in the editor.
6
+ */
7
+
8
+ /**
9
+ * Description of Ediidentifier
10
+ *
11
+ * @author shubhs
12
+ */
13
+ class Logicbroker_Fulfillment_Model_System_Config_Source_Optionvalues {
14
+
15
+
16
+ public function toOptionArray()
17
+ {
18
+
19
+ $optionsArray = $this->getOptionValue();
20
+ if(is_array($optionsArray)){
21
+ array_unshift($optionsArray,array('value' => '', 'label' => Mage::helper('logicbroker')->__('--Please Select--')));
22
+ array_push($optionsArray,array('value' => 'addnew', 'label' => Mage::helper('logicbroker')->__('Add new code')));
23
+ }
24
+ else
25
+ {
26
+ $optionsArray = array(array('value' => '', 'label' => Mage::helper('logicbroker')->__('--Please Select--')),
27
+ array('value' => 'addnew', 'label' => Mage::helper('logicbroker')->__('Add new code')));
28
+ }
29
+ // echo '<pre>';
30
+ // print_r($optionsArray);
31
+ // die('save ememm');
32
+ return $optionsArray;
33
+
34
+ }
35
+
36
+ public function getOptionValue()
37
+ {
38
+ $integration = Mage::getStoreConfig('logicbroker_integration/integration/supplier_attribute');
39
+ $logicbrokerCollection = Mage::getModel('logicbroker/supplier')->getCollection();
40
+ $attributeArray = array();
41
+ if($integration != null && $integration)
42
+ {
43
+ $attributeDetails = Mage::getSingleton("eav/config")->getAttribute("catalog_product", $integration);
44
+ $options = $attributeDetails->getSource()->getAllOptions(false);
45
+ foreach ($options as $option) {
46
+
47
+ $attributeArray[] = array('value'=>$option["label"],'label' => Mage::helper('logicbroker')->__(strtolower($option["label"])));
48
+ }
49
+ }else
50
+ {
51
+ $logicbrokerCollection ->addFieldToFilter(array('is_update', 'verified'), array('1', '0'))->addFieldToFilter('status','')
52
+ ->addFieldToSelect(array('company_id', 'magento_vendor_code'));
53
+ $comapnyIds = $logicbrokerCollection->getData();
54
+ if (count($comapnyIds) > 0) {
55
+ foreach ($comapnyIds as $key=>$value) {
56
+ $attributeArray[] = array('value'=>$value['magento_vendor_code'],'label' => Mage::helper('logicbroker')->__(strtolower($value['magento_vendor_code'])));
57
+ }
58
+ }
59
+ }
60
+
61
+ return $attributeArray;
62
+
63
+ }
64
+ }
65
+
66
+ ?>
package.xml CHANGED
@@ -1,18 +1,18 @@
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>logicbroker</name>
4
- <version>1.0.1</version>
5
  <stability>stable</stability>
6
  <license uri="http://logicbroker.com/portfolio/magento/license">Customer License</license>
7
  <channel>community</channel>
8
  <extends/>
9
  <summary>logicbroker enables Magento merchants to seamlessly connect with vendors via EDI for drop ship automation.</summary>
10
- <description>logicbroker is the most complete eCommerce integration platform available and offers a true end-to-end EDI solution for Magento. Beyond its EDI capabilities, logicbroker&#x2019;s flexible connectivity automates and simplifies tasks like drop ship deployment and omni-channel retailing. logicbroker connects Magento to backend systems like ERPs (Dynamics, Netsuite, Exact), accounting software (QuickBooks), and order management systems (M.O.M) to seamlessly exchange information</description>
11
  <notes>Stable</notes>
12
  <authors><author><name>Logicbroker</name><user>Logicbroker</user><email>magentoext@logicbroker.com</email></author></authors>
13
- <date>2014-05-08</date>
14
- <time>06:50:55</time>
15
- <contents><target name="magecommunity"><dir name="Logicbroker"><dir name="Fulfillment"><dir name="Block"><dir name="Adminhtml"><dir name="Logicbroker"><dir name="Edit"><file name="Form.php" hash="f6cda7c2b3c2abde7ead267cd5225bdd"/><dir name="Tab"><file name="Form.php" hash="d8fa50be85d9803260293ca302d29845"/></dir><file name="Tabs.php" hash="aa50ffbd40244b75544eaa0beee7424b"/></dir><file name="Edit.php" hash="f65072acf0dfbffd87bbc8f130289d44"/><file name="Grid.php" hash="4647fad316e3b59678e6a7d6edb9f278"/></dir><file name="Logicbroker.php" hash="263acd2c2bcc377c61c12b28e28f496c"/><dir name="System"><dir name="Config"><dir name="Fieldset"><file name="Hint.php" hash="fb5c84fc3a92224fe96bcf772ce4e3e2"/></dir><file name="Submitbutton.php" hash="ae26fe2eddd677ac0bc172604c295f93"/></dir></dir><dir name="Widget"><dir name="Grid"><dir name="Column"><dir name="Renderer"><file name="Textaction.php" hash="91e820b46d5fd27ea46db4ca5305a516"/></dir></dir></dir></dir></dir></dir><dir name="Helper"><file name="Data.php" hash="ead0d884761acefd39073dfef7ce7cd0"/></dir><dir name="Model"><file name="Abstract.php" hash="6a4f54539e45483251c738cac17485f1"/><file name="Apicreate.php" hash="f525ac3eb7677d00486ed5ac8b9dffce"/><file name="Email.php" hash="9db5cb8066f1ae5695689fbb424d4a2a"/><file name="Excelxml.php" hash="e38e32160200c8597f4681440765659c"/><file name="Infromlogicbroker.php" hash="dcf042dfa253809f1f6e2886d40e6414"/><file name="Logicbroker.php" hash="1b3342e6eb17ce1e0b387af837b286f1"/><file name="Observer.php" hash="6eb1b76791aa5147d8d3e4429cc3c89e"/><dir name="Resource"><dir name="Supplier"><file name="Collection.php" hash="8d34cf5db7ea454507f6e482c1980487"/></dir><file name="Supplier.php" hash="70a06dfb0429b2e92052a6dc61eb822a"/></dir><file name="Supplier.php" hash="1b9f082644c8af7320c6758af51e96b2"/><file name="Synchronize.php" hash="19a6bb2daa3231fbb469bb12cbfc41ee"/><dir name="System"><dir name="Config"><dir name="Source"><file name="Attributecodes.php" hash="4b9d097406e0c4b5030fc739a798fd1a"/><file name="Ediqualifier.php" hash="d25512bfd273a84b7628fab7103c5be3"/><file name="Optionvalues.php" hash="70cc5a5c7c72f6a75b6d5266467ff8c9"/></dir></dir></dir></dir><dir name="controllers"><dir name="Adminhtml"><file name="LogicbrokerController.php" hash="7f723e921e1ed38492a8c95c265fd8bd"/></dir></dir><dir name="data"><dir name="logicbroker_setup"><file name="data-install-1.0.0.php" hash="dc8db696c806e0ef43dd7fe151e781e5"/></dir></dir><dir name="etc"><file name="adminhtml.xml" hash="aa3bcde0b8f36840f82b7079dda4abc4"/><file name="config.xml" hash="5c128d32c6953e50c5f7c61d33ff3676"/><file name="jstranslator.xml" hash="c4401a0c80dd792208ee3bbdbe6c27ff"/><file name="system.xml" hash="319d06d78cf529d81dc63ace510ce2d8"/></dir><dir name="sql"><dir name="logicbroker_setup"><file name="mysql4-install-1.0.0.php" hash="e39fe4850f06551e745a646274d53410"/></dir></dir></dir></dir></target><target name="magedesign"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="template"><dir name="logicbroker"><dir name="system"><dir name="config"><dir name="fieldset"><file name="hint.phtml" hash="7b409b95a71e7315fe672ffe075a6323"/></dir><file name="submitbutton.phtml" hash="c524672897bab938256b7dd3e101606b"/></dir></dir></dir></dir><dir name="layout"><file name="logicbroker.xml" hash="7a8d87801975b329f79a94f1a3b73302"/></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Logicbroker_Fulfillment.xml" hash="423c11fbb087bcb8c82e4a39138ae492"/></dir></target><target name="magelocale"><dir name="en_US"><file name="Logicbroker_Fulfillment.csv" hash="34e85a999b73c4a216eed04dfffa756d"/><dir name="template"><dir name="email"><file name="logicbroker.html" hash="20ec1acaa64500708bdc6b1c86a33668"/></dir></dir></dir></target></contents>
16
  <compatible/>
17
  <dependencies><required><php><min>5.1.0</min><max>6.0.0</max></php></required></dependencies>
18
  </package>
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>logicbroker</name>
4
+ <version>1.0.2</version>
5
  <stability>stable</stability>
6
  <license uri="http://logicbroker.com/portfolio/magento/license">Customer License</license>
7
  <channel>community</channel>
8
  <extends/>
9
  <summary>logicbroker enables Magento merchants to seamlessly connect with vendors via EDI for drop ship automation.</summary>
10
+ <description>logicbroker is the most complete eCommerce integration platform available and offers a true end-to-end EDI solution for Magento. Beyond its EDI capabilities, logicbroker&amp;#x2019;s flexible connectivity automates and simplifies tasks like drop ship deployment and omni-channel retailing. logicbroker connects Magento to backend systems like ERPs (Dynamics, Netsuite, Exact), accounting software (QuickBooks), and order management systems (M.O.M) to seamlessly exchange information</description>
11
  <notes>Stable</notes>
12
  <authors><author><name>Logicbroker</name><user>Logicbroker</user><email>magentoext@logicbroker.com</email></author></authors>
13
+ <date>2014-05-21</date>
14
+ <time>14:43:26</time>
15
+ <contents><target name="magecommunity"><dir name="Logicbroker"><dir name="Fulfillment"><dir name="Block"><dir name="Adminhtml"><dir name="Logicbroker"><dir name="Edit"><file name="Form.php" hash="f6cda7c2b3c2abde7ead267cd5225bdd"/><dir name="Tab"><file name="Form.php" hash="d8fa50be85d9803260293ca302d29845"/></dir><file name="Tabs.php" hash="aa50ffbd40244b75544eaa0beee7424b"/></dir><file name="Edit.php" hash="f65072acf0dfbffd87bbc8f130289d44"/><file name="Grid.php" hash="4647fad316e3b59678e6a7d6edb9f278"/></dir><file name="Logicbroker.php" hash="263acd2c2bcc377c61c12b28e28f496c"/><dir name="System"><dir name="Config"><dir name="Fieldset"><file name="Hint.php" hash="fb5c84fc3a92224fe96bcf772ce4e3e2"/></dir><file name="Submitbutton.php" hash="ae26fe2eddd677ac0bc172604c295f93"/></dir></dir><dir name="Widget"><dir name="Grid"><dir name="Column"><dir name="Renderer"><file name="Textaction.php" hash="91e820b46d5fd27ea46db4ca5305a516"/></dir></dir></dir></dir></dir></dir><dir name="Helper"><file name="Data.php" hash="ead0d884761acefd39073dfef7ce7cd0"/></dir><dir name="Model"><file name="Abstract.php" hash="6a4f54539e45483251c738cac17485f1"/><file name="Apicreate.php" hash="f525ac3eb7677d00486ed5ac8b9dffce"/><file name="Email.php" hash="9db5cb8066f1ae5695689fbb424d4a2a"/><file name="Excelxml.php" hash="e38e32160200c8597f4681440765659c"/><file name="Infromlogicbroker.php" hash="dcf042dfa253809f1f6e2886d40e6414"/><file name="Logicbroker.php" hash="1b3342e6eb17ce1e0b387af837b286f1"/><file name="Observer.php" hash="6eb1b76791aa5147d8d3e4429cc3c89e"/><dir name="Resource"><dir name="Supplier"><file name="Collection.php" hash="8d34cf5db7ea454507f6e482c1980487"/></dir><file name="Supplier.php" hash="70a06dfb0429b2e92052a6dc61eb822a"/></dir><file name="Supplier.php" hash="1b9f082644c8af7320c6758af51e96b2"/><file name="Synchronize.php" hash="19a6bb2daa3231fbb469bb12cbfc41ee"/><dir name="System"><dir name="Config"><dir name="Source"><file name="Attributecodes.php" hash="4b9d097406e0c4b5030fc739a798fd1a"/><file name="Ediqualifier.php" hash="d25512bfd273a84b7628fab7103c5be3"/><file name="Optionvalues.php" hash="70cc5a5c7c72f6a75b6d5266467ff8c9"/></dir></dir></dir></dir><dir name="controllers"><dir name="Adminhtml"><file name="LogicbrokerController.php" hash="7f723e921e1ed38492a8c95c265fd8bd"/></dir></dir><dir name="data"><dir name="logicbroker_setup"><file name="data-install-1.0.0.php" hash="dc8db696c806e0ef43dd7fe151e781e5"/></dir></dir><dir name="etc"><file name="adminhtml.xml" hash="aa3bcde0b8f36840f82b7079dda4abc4"/><file name="config.xml" hash="5c128d32c6953e50c5f7c61d33ff3676"/><file name="jstranslator.xml" hash="c4401a0c80dd792208ee3bbdbe6c27ff"/><file name="system.xml" hash="319d06d78cf529d81dc63ace510ce2d8"/></dir><dir name="sql"><dir name="logicbroker_setup"><file name="mysql4-install-1.0.0.php" hash="e619a2193ab799d56b72f84420e167a7"/></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Logicbroker_Fulfillment.xml" hash="423c11fbb087bcb8c82e4a39138ae492"/></dir></target><target name="magedesign"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="layout"><file name="logicbroker.xml" hash="7a8d87801975b329f79a94f1a3b73302"/></dir><dir name="template"><dir name="logicbroker"><dir name="system"><dir name="config"><dir name="fieldset"><file name="hint.phtml" hash="7b409b95a71e7315fe672ffe075a6323"/></dir><file name="submitbutton.phtml" hash="c524672897bab938256b7dd3e101606b"/></dir></dir></dir></dir></dir></dir></dir></target><target name="magelocale"><dir name="en_US"><file name="Logicbroker_Fulfillment.csv" hash="34e85a999b73c4a216eed04dfffa756d"/></dir></target><target name="mage"><dir name="includes"><dir name="src"><dir name="Logicbroker"><dir name="Fulfillment"><dir name="controllers"><dir name="Adminhtml"><file name="LogicbrokerController.php" hash="7f723e921e1ed38492a8c95c265fd8bd"/></dir></dir></dir></dir><file name="Logicbroker_Fulfillment_Block_Adminhtml_Logicbroker.php" hash="263acd2c2bcc377c61c12b28e28f496c"/><file name="Logicbroker_Fulfillment_Block_Adminhtml_Logicbroker_Edit.php" hash="f65072acf0dfbffd87bbc8f130289d44"/><file name="Logicbroker_Fulfillment_Block_Adminhtml_Logicbroker_Edit_Form.php" hash="f6cda7c2b3c2abde7ead267cd5225bdd"/><file name="Logicbroker_Fulfillment_Block_Adminhtml_Logicbroker_Edit_Tab_Form.php" hash="d8fa50be85d9803260293ca302d29845"/><file name="Logicbroker_Fulfillment_Block_Adminhtml_Logicbroker_Edit_Tabs.php" hash="aa50ffbd40244b75544eaa0beee7424b"/><file name="Logicbroker_Fulfillment_Block_Adminhtml_Logicbroker_Grid.php" hash="4647fad316e3b59678e6a7d6edb9f278"/><file name="Logicbroker_Fulfillment_Block_Adminhtml_System_Config_Fieldset_Hint.php" hash="fb5c84fc3a92224fe96bcf772ce4e3e2"/><file name="Logicbroker_Fulfillment_Block_Adminhtml_System_Config_Submitbutton.php" hash="ae26fe2eddd677ac0bc172604c295f93"/><file name="Logicbroker_Fulfillment_Block_Adminhtml_Widget_Grid_Column_Renderer_Textaction.php" hash="91e820b46d5fd27ea46db4ca5305a516"/><file name="Logicbroker_Fulfillment_Helper_Data.php" hash="ead0d884761acefd39073dfef7ce7cd0"/><file name="Logicbroker_Fulfillment_Model_Abstract.php" hash="6a4f54539e45483251c738cac17485f1"/><file name="Logicbroker_Fulfillment_Model_Apicreate.php" hash="f525ac3eb7677d00486ed5ac8b9dffce"/><file name="Logicbroker_Fulfillment_Model_Email.php" hash="9db5cb8066f1ae5695689fbb424d4a2a"/><file name="Logicbroker_Fulfillment_Model_Excelxml.php" hash="e38e32160200c8597f4681440765659c"/><file name="Logicbroker_Fulfillment_Model_Infromlogicbroker.php" hash="dcf042dfa253809f1f6e2886d40e6414"/><file name="Logicbroker_Fulfillment_Model_Logicbroker.php" hash="1b3342e6eb17ce1e0b387af837b286f1"/><file name="Logicbroker_Fulfillment_Model_Observer.php" hash="6eb1b76791aa5147d8d3e4429cc3c89e"/><file name="Logicbroker_Fulfillment_Model_Resource_Supplier.php" hash="70a06dfb0429b2e92052a6dc61eb822a"/><file name="Logicbroker_Fulfillment_Model_Resource_Supplier_Collection.php" hash="8d34cf5db7ea454507f6e482c1980487"/><file name="Logicbroker_Fulfillment_Model_Supplier.php" hash="1b9f082644c8af7320c6758af51e96b2"/><file name="Logicbroker_Fulfillment_Model_Synchronize.php" hash="19a6bb2daa3231fbb469bb12cbfc41ee"/><file name="Logicbroker_Fulfillment_Model_System_Config_Source_Attributecodes.php" hash="4b9d097406e0c4b5030fc739a798fd1a"/><file name="Logicbroker_Fulfillment_Model_System_Config_Source_Ediqualifier.php" hash="d25512bfd273a84b7628fab7103c5be3"/><file name="Logicbroker_Fulfillment_Model_System_Config_Source_Optionvalues.php" hash="70cc5a5c7c72f6a75b6d5266467ff8c9"/></dir></dir></target></contents>
16
  <compatible/>
17
  <dependencies><required><php><min>5.1.0</min><max>6.0.0</max></php></required></dependencies>
18
  </package>