Manv_storelocator - Version 1.1.1

Version Notes

This store locator allows you to show any location on the map in your store.

Download this release

Release Info

Developer Manvendra Sharma
Extension Manv_storelocator
Version 1.1.1
Comparing to
See all releases


Version 1.1.1

app/code/community/Manv/Storelocator/Block/Adminhtml/Storelocator.php ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+
4
+ class Manv_Storelocator_Block_Adminhtml_Storelocator extends Mage_Adminhtml_Block_Widget_Grid_Container{
5
+
6
+ public function __construct()
7
+ {
8
+
9
+ $this->_controller = "adminhtml_storelocator";
10
+ $this->_blockGroup = "storelocator";
11
+ $this->_headerText = Mage::helper("storelocator")->__("Storelocator Manager");
12
+ $this->_addButtonLabel = Mage::helper("storelocator")->__("Add New Item");
13
+ parent::__construct();
14
+
15
+ }
16
+
17
+ }
app/code/community/Manv/Storelocator/Block/Adminhtml/Storelocator/Edit.php ADDED
@@ -0,0 +1,44 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Manv_Storelocator_Block_Adminhtml_Storelocator_Edit extends Mage_Adminhtml_Block_Widget_Form_Container
4
+ {
5
+ public function __construct()
6
+ {
7
+
8
+ parent::__construct();
9
+ $this->_objectId = "id";
10
+ $this->_blockGroup = "storelocator";
11
+ $this->_controller = "adminhtml_storelocator";
12
+ $this->_updateButton("save", "label", Mage::helper("storelocator")->__("Save Item"));
13
+ $this->_updateButton("delete", "label", Mage::helper("storelocator")->__("Delete Item"));
14
+
15
+ $this->_addButton("saveandcontinue", array(
16
+ "label" => Mage::helper("storelocator")->__("Save And Continue Edit"),
17
+ "onclick" => "saveAndContinueEdit()",
18
+ "class" => "save",
19
+ ), -100);
20
+
21
+
22
+
23
+ $this->_formScripts[] = "
24
+
25
+ function saveAndContinueEdit(){
26
+ editForm.submit($('edit_form').action+'back/edit/');
27
+ }
28
+ ";
29
+ }
30
+
31
+ public function getHeaderText()
32
+ {
33
+ if( Mage::registry("storelocator_data") && Mage::registry("storelocator_data")->getId() ){
34
+
35
+ return Mage::helper("storelocator")->__("Edit Item '%s'", $this->htmlEscape(Mage::registry("storelocator_data")->getId()));
36
+
37
+ }
38
+ else{
39
+
40
+ return Mage::helper("storelocator")->__("Add Item");
41
+
42
+ }
43
+ }
44
+ }
app/code/community/Manv/Storelocator/Block/Adminhtml/Storelocator/Edit/Form.php ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Manv_Storelocator_Block_Adminhtml_Storelocator_Edit_Form extends Mage_Adminhtml_Block_Widget_Form
3
+ {
4
+ protected function _prepareForm()
5
+ {
6
+ $form = new Varien_Data_Form(array(
7
+ "id" => "edit_form",
8
+ "action" => $this->getUrl("*/*/save", array("id" => $this->getRequest()->getParam("id"))),
9
+ "method" => "post",
10
+ "enctype" =>"multipart/form-data",
11
+ )
12
+ );
13
+ $form->setUseContainer(true);
14
+ $this->setForm($form);
15
+ return parent::_prepareForm();
16
+ }
17
+ }
app/code/community/Manv/Storelocator/Block/Adminhtml/Storelocator/Edit/Tab/Form.php ADDED
@@ -0,0 +1,93 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Manv_Storelocator_Block_Adminhtml_Storelocator_Edit_Tab_Form extends Mage_Adminhtml_Block_Widget_Form
3
+ {
4
+ protected function _prepareForm()
5
+ {
6
+
7
+ $form = new Varien_Data_Form();
8
+ $this->setForm($form);
9
+ $fieldset = $form->addFieldset("storelocator_form", array("legend"=>Mage::helper("storelocator")->__("Item information")));
10
+
11
+
12
+ $fieldset->addField("name", "text", array(
13
+ "label" => Mage::helper("storelocator")->__("name"),
14
+ "name" => "name",
15
+ ));
16
+
17
+ $fieldset->addField("address", "text", array(
18
+ "label" => Mage::helper("storelocator")->__("address"),
19
+ "name" => "address",
20
+ ));
21
+
22
+ $fieldset->addField("zipcode", "text", array(
23
+ "label" => Mage::helper("storelocator")->__("zipcode"),
24
+ "name" => "zipcode",
25
+ ));
26
+
27
+ $fieldset->addField("city", "text", array(
28
+ "label" => Mage::helper("storelocator")->__("city"),
29
+ "name" => "city",
30
+ ));
31
+
32
+ $fieldset->addField("country_id", "text", array(
33
+ "label" => Mage::helper("storelocator")->__("country_id"),
34
+ "name" => "country_id",
35
+ ));
36
+
37
+ $fieldset->addField("phone", "text", array(
38
+ "label" => Mage::helper("storelocator")->__("phone"),
39
+ "name" => "phone",
40
+ ));
41
+
42
+ $fieldset->addField("fax", "text", array(
43
+ "label" => Mage::helper("storelocator")->__("fax"),
44
+ "name" => "fax",
45
+ ));
46
+
47
+ $fieldset->addField("description", "text", array(
48
+ "label" => Mage::helper("storelocator")->__("description"),
49
+ "name" => "description",
50
+ ));
51
+
52
+ $fieldset->addField("store_url", "text", array(
53
+ "label" => Mage::helper("storelocator")->__("store_url"),
54
+ "name" => "store_url",
55
+ ));
56
+
57
+ $fieldset->addField('image', 'image', array(
58
+ 'label' => Mage::helper('storelocator')->__('image'),
59
+ 'name' => 'image',
60
+ 'note' => '(*.jpg, *.png, *.gif)',
61
+ ));
62
+ $fieldset->addField('marker', 'image', array(
63
+ 'label' => Mage::helper('storelocator')->__('marker'),
64
+ 'name' => 'marker',
65
+ 'note' => '(*.jpg, *.png, *.gif)',
66
+ ));
67
+ $fieldset->addField("lat", "text", array(
68
+ "label" => Mage::helper("storelocator")->__("lat"),
69
+ "name" => "lat",
70
+ ));
71
+
72
+ $fieldset->addField("longt", "text", array(
73
+ "label" => Mage::helper("storelocator")->__("longt"),
74
+ "name" => "longt",
75
+ ));
76
+
77
+ $fieldset->addField('status', 'select', array(
78
+ 'label' => Mage::helper('storelocator')->__('status'),
79
+ 'values' => Manv_Storelocator_Block_Adminhtml_Storelocator_Grid::getValueArray13(),
80
+ 'name' => 'status',
81
+ ));
82
+
83
+ if (Mage::getSingleton("adminhtml/session")->getStorelocatorData())
84
+ {
85
+ $form->setValues(Mage::getSingleton("adminhtml/session")->getStorelocatorData());
86
+ Mage::getSingleton("adminhtml/session")->setStorelocatorData(null);
87
+ }
88
+ elseif(Mage::registry("storelocator_data")) {
89
+ $form->setValues(Mage::registry("storelocator_data")->getData());
90
+ }
91
+ return parent::_prepareForm();
92
+ }
93
+ }
app/code/community/Manv/Storelocator/Block/Adminhtml/Storelocator/Edit/Tabs.php ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Manv_Storelocator_Block_Adminhtml_Storelocator_Edit_Tabs extends Mage_Adminhtml_Block_Widget_Tabs
3
+ {
4
+ public function __construct()
5
+ {
6
+ parent::__construct();
7
+ $this->setId("storelocator_tabs");
8
+ $this->setDestElementId("edit_form");
9
+ $this->setTitle(Mage::helper("storelocator")->__("Item Information"));
10
+ }
11
+ protected function _beforeToHtml()
12
+ {
13
+ $this->addTab("form_section", array(
14
+ "label" => Mage::helper("storelocator")->__("Item Information"),
15
+ "title" => Mage::helper("storelocator")->__("Item Information"),
16
+ "content" => $this->getLayout()->createBlock("storelocator/adminhtml_storelocator_edit_tab_form")->toHtml(),
17
+ ));
18
+ return parent::_beforeToHtml();
19
+ }
20
+
21
+ }
app/code/community/Manv/Storelocator/Block/Adminhtml/Storelocator/Grid.php ADDED
@@ -0,0 +1,126 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Manv_Storelocator_Block_Adminhtml_Storelocator_Grid extends Mage_Adminhtml_Block_Widget_Grid
4
+ {
5
+
6
+ public function __construct()
7
+ {
8
+ parent::__construct();
9
+ $this->setId("storelocatorGrid");
10
+ $this->setDefaultSort("id");
11
+ $this->setDefaultDir("ASC");
12
+ $this->setSaveParametersInSession(true);
13
+ }
14
+
15
+ protected function _prepareCollection()
16
+ {
17
+ $collection = Mage::getModel("storelocator/storelocator")->getCollection();
18
+ $this->setCollection($collection);
19
+ return parent::_prepareCollection();
20
+ }
21
+ protected function _prepareColumns()
22
+ {
23
+ $this->addColumn("id", array(
24
+ "header" => Mage::helper("storelocator")->__("ID"),
25
+ "align" =>"right",
26
+ "width" => "50px",
27
+ "type" => "number",
28
+ "index" => "id",
29
+ ));
30
+
31
+ $this->addColumn("name", array(
32
+ "header" => Mage::helper("storelocator")->__("name"),
33
+ "index" => "name",
34
+ ));
35
+ $this->addColumn("address", array(
36
+ "header" => Mage::helper("storelocator")->__("address"),
37
+ "index" => "address",
38
+ ));
39
+ $this->addColumn("zipcode", array(
40
+ "header" => Mage::helper("storelocator")->__("zipcode"),
41
+ "index" => "zipcode",
42
+ ));
43
+ $this->addColumn("city", array(
44
+ "header" => Mage::helper("storelocator")->__("city"),
45
+ "index" => "city",
46
+ ));
47
+ $this->addColumn("country_id", array(
48
+ "header" => Mage::helper("storelocator")->__("country_id"),
49
+ "index" => "country_id",
50
+ ));
51
+ $this->addColumn("phone", array(
52
+ "header" => Mage::helper("storelocator")->__("phone"),
53
+ "index" => "phone",
54
+ ));
55
+ $this->addColumn("fax", array(
56
+ "header" => Mage::helper("storelocator")->__("fax"),
57
+ "index" => "fax",
58
+ ));
59
+ $this->addColumn("description", array(
60
+ "header" => Mage::helper("storelocator")->__("description"),
61
+ "index" => "description",
62
+ ));
63
+ $this->addColumn("store_url", array(
64
+ "header" => Mage::helper("storelocator")->__("store_url"),
65
+ "index" => "store_url",
66
+ ));
67
+ $this->addColumn("lat", array(
68
+ "header" => Mage::helper("storelocator")->__("lat"),
69
+ "index" => "lat",
70
+ ));
71
+ $this->addColumn("longt", array(
72
+ "header" => Mage::helper("storelocator")->__("longt"),
73
+ "index" => "longt",
74
+ ));
75
+ $this->addColumn('status', array(
76
+ 'header' => Mage::helper('storelocator')->__('status'),
77
+ 'index' => 'status',
78
+ 'type' => 'options',
79
+ 'options'=>Manv_Storelocator_Block_Adminhtml_Storelocator_Grid::getOptionArray13(),
80
+ ));
81
+
82
+ $this->addExportType('*/*/exportCsv', Mage::helper('sales')->__('CSV'));
83
+ $this->addExportType('*/*/exportExcel', Mage::helper('sales')->__('Excel'));
84
+
85
+ return parent::_prepareColumns();
86
+ }
87
+
88
+ public function getRowUrl($row)
89
+ {
90
+ return $this->getUrl("*/*/edit", array("id" => $row->getId()));
91
+ }
92
+
93
+
94
+
95
+ protected function _prepareMassaction()
96
+ {
97
+ $this->setMassactionIdField('id');
98
+ $this->getMassactionBlock()->setFormFieldName('ids');
99
+ $this->getMassactionBlock()->setUseSelectAll(true);
100
+ $this->getMassactionBlock()->addItem('remove_storelocator', array(
101
+ 'label'=> Mage::helper('storelocator')->__('Remove Storelocator'),
102
+ 'url' => $this->getUrl('*/adminhtml_storelocator/massRemove'),
103
+ 'confirm' => Mage::helper('storelocator')->__('Are you sure?')
104
+ ));
105
+ return $this;
106
+ }
107
+
108
+ static public function getOptionArray13()
109
+ {
110
+ $data_array=array();
111
+ $data_array[0]='Enable';
112
+ $data_array[1]='Disable';
113
+ return($data_array);
114
+ }
115
+ static public function getValueArray13()
116
+ {
117
+ $data_array=array();
118
+ foreach(Manv_Storelocator_Block_Adminhtml_Storelocator_Grid::getOptionArray13() as $k=>$v){
119
+ $data_array[]=array('value'=>$k,'label'=>$v);
120
+ }
121
+ return($data_array);
122
+
123
+ }
124
+
125
+
126
+ }
app/code/community/Manv/Storelocator/Block/Index.php ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Manv_Storelocator_Block_Index extends Mage_Core_Block_Template{
3
+
4
+
5
+
6
+
7
+
8
+ }
app/code/community/Manv/Storelocator/Helper/Data.php ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
1
+ <?php
2
+ class Manv_Storelocator_Helper_Data extends Mage_Core_Helper_Abstract
3
+ {
4
+ }
5
+
app/code/community/Manv/Storelocator/Model/Mysql4/Storelocator.php ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Manv_Storelocator_Model_Mysql4_Storelocator extends Mage_Core_Model_Mysql4_Abstract
3
+ {
4
+ protected function _construct()
5
+ {
6
+ $this->_init("storelocator/storelocator", "id");
7
+ }
8
+ }
app/code/community/Manv/Storelocator/Model/Mysql4/Storelocator/Collection.php ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Manv_Storelocator_Model_Mysql4_Storelocator_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract
3
+ {
4
+
5
+ public function _construct(){
6
+ $this->_init("storelocator/storelocator");
7
+ }
8
+
9
+
10
+
11
+ }
12
+
app/code/community/Manv/Storelocator/Model/Storelocator.php ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Manv_Storelocator_Model_Storelocator extends Mage_Core_Model_Abstract
4
+ {
5
+ protected function _construct(){
6
+
7
+ $this->_init("storelocator/storelocator");
8
+
9
+ }
10
+
11
+ }
12
+
app/code/community/Manv/Storelocator/controllers/Adminhtml/StorelocatorController.php ADDED
@@ -0,0 +1,253 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Manv_Storelocator_Adminhtml_StorelocatorController extends Mage_Adminhtml_Controller_Action
4
+ {
5
+ protected function _initAction()
6
+ {
7
+ $this->loadLayout()->_setActiveMenu("storelocator/storelocator")->_addBreadcrumb(Mage::helper("adminhtml")->__("Storelocator Manager"),Mage::helper("adminhtml")->__("Storelocator Manager"));
8
+ return $this;
9
+ }
10
+ public function indexAction()
11
+ {
12
+ $this->_title($this->__("Storelocator"));
13
+ $this->_title($this->__("Manager Storelocator"));
14
+
15
+ $this->_initAction();
16
+ $this->renderLayout();
17
+ }
18
+ public function editAction()
19
+ {
20
+ $this->_title($this->__("Storelocator"));
21
+ $this->_title($this->__("Storelocator"));
22
+ $this->_title($this->__("Edit Item"));
23
+
24
+ $id = $this->getRequest()->getParam("id");
25
+ $model = Mage::getModel("storelocator/storelocator")->load($id);
26
+ if ($model->getId()) {
27
+ Mage::register("storelocator_data", $model);
28
+ $this->loadLayout();
29
+ $this->_setActiveMenu("storelocator/storelocator");
30
+ $this->_addBreadcrumb(Mage::helper("adminhtml")->__("Storelocator Manager"), Mage::helper("adminhtml")->__("Storelocator Manager"));
31
+ $this->_addBreadcrumb(Mage::helper("adminhtml")->__("Storelocator Description"), Mage::helper("adminhtml")->__("Storelocator Description"));
32
+ $this->getLayout()->getBlock("head")->setCanLoadExtJs(true);
33
+ $this->_addContent($this->getLayout()->createBlock("storelocator/adminhtml_storelocator_edit"))->_addLeft($this->getLayout()->createBlock("storelocator/adminhtml_storelocator_edit_tabs"));
34
+ $this->renderLayout();
35
+ }
36
+ else {
37
+ Mage::getSingleton("adminhtml/session")->addError(Mage::helper("storelocator")->__("Item does not exist."));
38
+ $this->_redirect("*/*/");
39
+ }
40
+ }
41
+
42
+ public function newAction()
43
+ {
44
+
45
+ $this->_title($this->__("Storelocator"));
46
+ $this->_title($this->__("Storelocator"));
47
+ $this->_title($this->__("New Item"));
48
+
49
+ $id = $this->getRequest()->getParam("id");
50
+ $model = Mage::getModel("storelocator/storelocator")->load($id);
51
+
52
+ $data = Mage::getSingleton("adminhtml/session")->getFormData(true);
53
+ if (!empty($data)) {
54
+ $model->setData($data);
55
+ }
56
+
57
+ Mage::register("storelocator_data", $model);
58
+
59
+ $this->loadLayout();
60
+ $this->_setActiveMenu("storelocator/storelocator");
61
+
62
+ $this->getLayout()->getBlock("head")->setCanLoadExtJs(true);
63
+
64
+ $this->_addBreadcrumb(Mage::helper("adminhtml")->__("Storelocator Manager"), Mage::helper("adminhtml")->__("Storelocator Manager"));
65
+ $this->_addBreadcrumb(Mage::helper("adminhtml")->__("Storelocator Description"), Mage::helper("adminhtml")->__("Storelocator Description"));
66
+
67
+
68
+ $this->_addContent($this->getLayout()->createBlock("storelocator/adminhtml_storelocator_edit"))->_addLeft($this->getLayout()->createBlock("storelocator/adminhtml_storelocator_edit_tabs"));
69
+
70
+ $this->renderLayout();
71
+
72
+ }
73
+ public function saveAction()
74
+ {
75
+
76
+ $post_data=$this->getRequest()->getPost();
77
+
78
+
79
+ if ($post_data) {
80
+
81
+ try {
82
+
83
+
84
+ //save image
85
+ try{
86
+
87
+ if((bool)$post_data['image']['delete']==1) {
88
+
89
+ $post_data['image']='';
90
+
91
+ }
92
+ else {
93
+
94
+ unset($post_data['image']);
95
+
96
+ if (isset($_FILES)){
97
+
98
+ if ($_FILES['image']['name']) {
99
+
100
+ if($this->getRequest()->getParam("id")){
101
+ $model = Mage::getModel("storelocator/storelocator")->load($this->getRequest()->getParam("id"));
102
+ if($model->getData('image')){
103
+ $io = new Varien_Io_File();
104
+ $io->rm(Mage::getBaseDir('media').DS.implode(DS,explode('/',$model->getData('image'))));
105
+ }
106
+ }
107
+ $path = Mage::getBaseDir('media') . DS . 'storelocator' . DS .'storelocator'.DS;
108
+ $uploader = new Varien_File_Uploader('image');
109
+ $uploader->setAllowedExtensions(array('jpg','png','gif'));
110
+ $uploader->setAllowRenameFiles(false);
111
+ $uploader->setFilesDispersion(false);
112
+ $destFile = $path.$_FILES['image']['name'];
113
+ $filename = $uploader->getNewFileName($destFile);
114
+ $uploader->save($path, $filename);
115
+
116
+ $post_data['image']='storelocator/storelocator/'.$filename;
117
+ }
118
+ }
119
+ }
120
+
121
+ } catch (Exception $e) {
122
+ Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
123
+ $this->_redirect('*/*/edit', array('id' => $this->getRequest()->getParam('id')));
124
+ return;
125
+ }
126
+ //save image
127
+
128
+ //save image
129
+ try{
130
+
131
+ if((bool)$post_data['marker']['delete']==1) {
132
+
133
+ $post_data['marker']='';
134
+
135
+ }
136
+ else {
137
+
138
+ unset($post_data['marker']);
139
+
140
+ if (isset($_FILES)){
141
+
142
+ if ($_FILES['marker']['name']) {
143
+
144
+ if($this->getRequest()->getParam("id")){
145
+ $model = Mage::getModel("storelocator/storelocator")->load($this->getRequest()->getParam("id"));
146
+ if($model->getData('marker')){
147
+ $io = new Varien_Io_File();
148
+ $io->rm(Mage::getBaseDir('media').DS.implode(DS,explode('/',$model->getData('marker'))));
149
+ }
150
+ }
151
+ $path = Mage::getBaseDir('media') . DS . 'storelocator' . DS .'storelocator'.DS;
152
+ $uploader = new Varien_File_Uploader('marker');
153
+ $uploader->setAllowedExtensions(array('jpg','png','gif'));
154
+ $uploader->setAllowRenameFiles(false);
155
+ $uploader->setFilesDispersion(false);
156
+ $destFile = $path.$_FILES['marker']['name'];
157
+ $filename = $uploader->getNewFileName($destFile);
158
+ $uploader->save($path, $filename);
159
+
160
+ $post_data['marker']='storelocator/storelocator/'.$filename;
161
+ }
162
+ }
163
+ }
164
+
165
+ } catch (Exception $e) {
166
+ Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
167
+ $this->_redirect('*/*/edit', array('id' => $this->getRequest()->getParam('id')));
168
+ return;
169
+ }
170
+ //save image
171
+
172
+
173
+ $model = Mage::getModel("storelocator/storelocator")
174
+ ->addData($post_data)
175
+ ->setId($this->getRequest()->getParam("id"))
176
+ ->save();
177
+
178
+ Mage::getSingleton("adminhtml/session")->addSuccess(Mage::helper("adminhtml")->__("Storelocator was successfully saved"));
179
+ Mage::getSingleton("adminhtml/session")->setStorelocatorData(false);
180
+
181
+ if ($this->getRequest()->getParam("back")) {
182
+ $this->_redirect("*/*/edit", array("id" => $model->getId()));
183
+ return;
184
+ }
185
+ $this->_redirect("*/*/");
186
+ return;
187
+ }
188
+ catch (Exception $e) {
189
+ Mage::getSingleton("adminhtml/session")->addError($e->getMessage());
190
+ Mage::getSingleton("adminhtml/session")->setStorelocatorData($this->getRequest()->getPost());
191
+ $this->_redirect("*/*/edit", array("id" => $this->getRequest()->getParam("id")));
192
+ return;
193
+ }
194
+
195
+ }
196
+ $this->_redirect("*/*/");
197
+ }
198
+
199
+
200
+
201
+ public function deleteAction()
202
+ {
203
+ if( $this->getRequest()->getParam("id") > 0 ) {
204
+ try {
205
+ $model = Mage::getModel("storelocator/storelocator");
206
+ $model->setId($this->getRequest()->getParam("id"))->delete();
207
+ Mage::getSingleton("adminhtml/session")->addSuccess(Mage::helper("adminhtml")->__("Item was successfully deleted"));
208
+ $this->_redirect("*/*/");
209
+ }
210
+ catch (Exception $e) {
211
+ Mage::getSingleton("adminhtml/session")->addError($e->getMessage());
212
+ $this->_redirect("*/*/edit", array("id" => $this->getRequest()->getParam("id")));
213
+ }
214
+ }
215
+ $this->_redirect("*/*/");
216
+ }
217
+
218
+
219
+ public function massRemoveAction()
220
+ {
221
+ try {
222
+ $ids = $this->getRequest()->getPost('ids', array());
223
+ foreach ($ids as $id) {
224
+ $model = Mage::getModel("storelocator/storelocator");
225
+ $model->setId($id)->delete();
226
+ }
227
+ Mage::getSingleton("adminhtml/session")->addSuccess(Mage::helper("adminhtml")->__("Item(s) was successfully removed"));
228
+ }
229
+ catch (Exception $e) {
230
+ Mage::getSingleton("adminhtml/session")->addError($e->getMessage());
231
+ }
232
+ $this->_redirect('*/*/');
233
+ }
234
+
235
+ /**
236
+ * Export order grid to CSV format
237
+ */
238
+ public function exportCsvAction()
239
+ {
240
+ $fileName = 'storelocator.csv';
241
+ $grid = $this->getLayout()->createBlock('storelocator/adminhtml_storelocator_grid');
242
+ $this->_prepareDownloadResponse($fileName, $grid->getCsvFile());
243
+ }
244
+ /**
245
+ * Export order grid to Excel XML format
246
+ */
247
+ public function exportExcelAction()
248
+ {
249
+ $fileName = 'storelocator.xml';
250
+ $grid = $this->getLayout()->createBlock('storelocator/adminhtml_storelocator_grid');
251
+ $this->_prepareDownloadResponse($fileName, $grid->getExcelFile($fileName));
252
+ }
253
+ }
app/code/community/Manv/Storelocator/controllers/IndexController.php ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Manv_Storelocator_IndexController extends Mage_Core_Controller_Front_Action{
3
+ public function IndexAction() {
4
+
5
+ $this->loadLayout();
6
+ $this->getLayout()->getBlock("head")->setTitle($this->__("StoreLocator"));
7
+ $breadcrumbs = $this->getLayout()->getBlock("breadcrumbs");
8
+ $breadcrumbs->addCrumb("home", array(
9
+ "label" => $this->__("Home Page"),
10
+ "title" => $this->__("Home Page"),
11
+ "link" => Mage::getBaseUrl()
12
+ ));
13
+
14
+ $breadcrumbs->addCrumb("storelocator", array(
15
+ "label" => $this->__("StoreLocator"),
16
+ "title" => $this->__("StoreLocator")
17
+ ));
18
+
19
+ $this->renderLayout();
20
+
21
+ }
22
+ }
app/code/community/Manv/Storelocator/etc/config.xml ADDED
@@ -0,0 +1,126 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <modules>
4
+ <Manv_Storelocator>
5
+ <version>1.1.1</version>
6
+ </Manv_Storelocator>
7
+ </modules>
8
+ <frontend>
9
+ <routers>
10
+ <storelocator>
11
+ <use>standard</use>
12
+ <args>
13
+ <module>Manv_Storelocator</module>
14
+ <frontName>storelocator</frontName>
15
+ </args>
16
+ </storelocator>
17
+ </routers>
18
+ <layout>
19
+ <updates>
20
+ <storelocator>
21
+ <file>storelocator.xml</file>
22
+ </storelocator>
23
+ </updates>
24
+ </layout>
25
+ </frontend>
26
+ <global>
27
+ <helpers>
28
+ <storelocator>
29
+ <class>Manv_Storelocator_Helper</class>
30
+ </storelocator>
31
+ </helpers>
32
+ <blocks>
33
+ <storelocator>
34
+ <class>Manv_Storelocator_Block</class>
35
+ </storelocator>
36
+ </blocks>
37
+ <models>
38
+ <storelocator>
39
+ <class>Manv_Storelocator_Model</class>
40
+ <resourceModel>storelocator_mysql4</resourceModel>
41
+ </storelocator>
42
+ <storelocator_mysql4>
43
+ <class>Manv_Storelocator_Model_Mysql4</class>
44
+ <entities>
45
+ <storelocator>
46
+ <table>manvstorelocator</table>
47
+ </storelocator>
48
+ </entities>
49
+ </storelocator_mysql4>
50
+ </models>
51
+ <resources>
52
+ <storelocator_setup>
53
+ <setup>
54
+ <module>Manv_Storelocator</module>
55
+ </setup>
56
+ <connection>
57
+ <use>core_setup</use>
58
+ </connection>
59
+ </storelocator_setup>
60
+ <storelocator_write>
61
+ <connection>
62
+ <use>core_write</use>
63
+ </connection>
64
+ </storelocator_write>
65
+ <storelocator_read>
66
+ <connection>
67
+ <use>core_read</use>
68
+ </connection>
69
+ </storelocator_read>
70
+ </resources>
71
+ </global>
72
+ <admin>
73
+ <routers>
74
+ <storelocator>
75
+ <use>admin</use>
76
+ <args>
77
+ <module>Manv_Storelocator</module>
78
+ <frontName>storelocator</frontName>
79
+ </args>
80
+ </storelocator>
81
+ </routers>
82
+ </admin>
83
+ <adminhtml>
84
+ <menu>
85
+ <storelocator module="storelocator">
86
+ <title>Storelocator</title>
87
+ <sort_order>100</sort_order>
88
+ <children>
89
+ <storelocator module="storelocator">
90
+ <title>Manage Storelocator</title>
91
+ <sort_order>0</sort_order>
92
+ <action>storelocator/adminhtml_storelocator</action>
93
+ </storelocator>
94
+ </children>
95
+ </storelocator>
96
+ </menu>
97
+ <acl>
98
+ <resources>
99
+ <all>
100
+ <title>Allow Everything</title>
101
+ </all>
102
+ <admin>
103
+ <children>
104
+ <storelocator translate="title" module="storelocator">
105
+ <title>Storelocator</title>
106
+ <sort_order>1000</sort_order>
107
+ <children>
108
+ <storelocator translate="title">
109
+ <title>Manage Storelocator</title>
110
+ <sort_order>0</sort_order>
111
+ </storelocator>
112
+ </children>
113
+ </storelocator>
114
+ </children>
115
+ </admin>
116
+ </resources>
117
+ </acl>
118
+ <layout>
119
+ <updates>
120
+ <storelocator>
121
+ <file>storelocator.xml</file>
122
+ </storelocator>
123
+ </updates>
124
+ </layout>
125
+ </adminhtml>
126
+ </config>
app/code/community/Manv/Storelocator/sql/storelocator_setup/mysql4-install-1.1.1.php ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ $installer = $this;
3
+ $installer->startSetup();
4
+ $sql=<<<SQLTEXT
5
+ create table manvstorelocator(id int not null auto_increment, name varchar(100), address varchar(255),zipcode varchar(100),city varchar(100),country_id varchar(100),phone varchar(100),fax varchar(100),description varchar(255),store_url varchar(100),image varchar(100),marker varchar(100),lat varchar(100),longt varchar(100),status varchar(100),primary key(id));
6
+
7
+ SQLTEXT;
8
+
9
+ $installer->run($sql);
10
+ //demo
11
+ Mage::getModel('core/url_rewrite')->setId(null);
12
+ //demo
13
+ $installer->endSetup();
14
+
app/design/frontend/base/default/layout/storelocator.xml ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <layout version="1.1.1">
3
+ <storelocator_index_index>
4
+ <reference name="root">
5
+ <action method="setTemplate"><template>page/1column.phtml</template></action>
6
+ </reference>
7
+ <reference name="content">
8
+ <block type="storelocator/index" name="storelocator_index" template="storelocator/index.phtml"/>
9
+ </reference>
10
+ </storelocator_index_index>
11
+ </layout>
12
+
app/design/frontend/base/default/template/storelocator/index.phtml ADDED
@@ -0,0 +1,91 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ $connection = Mage::getSingleton('core/resource')->getConnection('core_write');
3
+ $sql1 = $connection->query("select * from manvstorelocator order by id limit 1" );
4
+ $row1 = $sql1->fetch();
5
+ $latitudex = $row1['lat'];
6
+ $longitudex = $row1['longt'];
7
+ $addressx = $row1['address'];
8
+ ?>
9
+
10
+ <script src="http://code.jquery.com/jquery-1.10.2.min.js" type="text/javascript"></script>
11
+ <script src="https://maps.google.com/maps/api/js?sensor=false" type="text/javascript"></script>
12
+ <script type="text/javascript">
13
+
14
+ function map_xxx(x,y,z)
15
+ {
16
+ var latitude = x; // parseFloat("26.850883100000000000");
17
+ var longitude = y; // parseFloat("75.824783600000040000");
18
+ var address = z; // "Rohini, New Delhi, Delhi, India";
19
+ var latlngPos = new google.maps.LatLng(latitude,longitude);
20
+
21
+ // Set up options for the Google map
22
+ var myOptions = {
23
+ zoom: 10,
24
+ center: latlngPos,
25
+ mapTypeId: google.maps.MapTypeId.ROADMAP,
26
+ zoomControlOptions: true,
27
+ zoomControlOptions: {
28
+ style: google.maps.ZoomControlStyle.LARGE
29
+ }
30
+ };
31
+ // Define the map
32
+ map = new google.maps.Map(document.getElementById("map"), myOptions);
33
+ // Add the marker
34
+ var marker = new google.maps.Marker({
35
+ position: latlngPos,
36
+ map: map,
37
+ draggable: false,
38
+ title: address
39
+ });
40
+
41
+ };
42
+ </script>
43
+
44
+ <body onload="map_xxx('<?php echo $latitudex ?>','<?php echo $longitudex; ?>','<?php echo $addressx; ?>');">
45
+
46
+ <table id="map_xxx" style="width:900px; border:10px;">
47
+ <tr><td style="width:400px;">
48
+ <?php
49
+ $sql = $connection->query("select * from manvstorelocator" );
50
+ while($row = $sql->fetch())
51
+ {?>
52
+ <table id="store-table" class="store-table">
53
+ <tr>
54
+ <td rowspan="8" class="store-image">
55
+ <img src="<?php echo Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_MEDIA).$row['image']; ?>" alt="Manvendra sharma" width="50">
56
+ </td>
57
+ </tr>
58
+ <tr>
59
+ <td>
60
+ <h3 class="store_name" onclick="map_xxx('<?php echo $row['lat']; ?>','<?php echo $row['longt']; ?>','<?php echo $row['address']; ?>');"><?php echo $row['name']; ?></h3>
61
+ </td>
62
+ </tr>
63
+ <tr>
64
+ <td class="col-address"><?php echo $row['city']; ?></td>
65
+ </tr>
66
+ <tr>
67
+ <?php
68
+ $add = $row['zipcode'].$row['address'];
69
+ ?>
70
+ <td class="col-address"><?php echo $add; ?></td>
71
+ </tr>
72
+ <tr>
73
+ <td class="col-address"><?php echo $row['country_id']; ?> </td>
74
+ </tr>
75
+ <tr>
76
+ <td>Website : <a href="<?php echo $row['store_url']; ?>" target="_blank"><?php echo $row['store_url']; ?></a></td>
77
+ </tr>
78
+ <tr>
79
+ <td> Phone :<?php echo $row['phone']; ?> </td>
80
+ </tr>
81
+ <tr>
82
+ <td> Fax :<?php echo $row['fax']; ?></td>
83
+ </tr>
84
+ </table>
85
+ <?php } ?>
86
+
87
+ </td>
88
+
89
+ <td style="width:500px;">
90
+ <div id="map" style="width:500px; height:500px;"></div>
91
+ </td></tr></table>
app/etc/modules/Manv_Storelocator.xml ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <modules>
4
+ <Manv_Storelocator>
5
+ <active>true</active>
6
+ <codePool>community</codePool>
7
+ <version>1.1.1</version>
8
+ </Manv_Storelocator>
9
+ </modules>
10
+ </config>
package.xml ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <package>
3
+ <name>Manv_storelocator</name>
4
+ <version>1.1.1</version>
5
+ <stability>stable</stability>
6
+ <license>OSL</license>
7
+ <channel>community</channel>
8
+ <extends/>
9
+ <summary>This store locator allows you to show any location on the map in your store.</summary>
10
+ <description>This store locator allows you to show any location on the map in your store.</description>
11
+ <notes>This store locator allows you to show any location on the map in your store.</notes>
12
+ <authors><author><name>Manvendra Sharma</name><user>sharmamanvendra</user><email>sharmamanvendra6@gmail.com</email></author></authors>
13
+ <date>2014-01-02</date>
14
+ <time>10:34:08</time>
15
+ <contents><target name="magecommunity"><dir name="Manv"><dir name="Storelocator"><dir name="Block"><dir name="Adminhtml"><dir name="Storelocator"><dir name="Edit"><file name="Form.php" hash="183787af3dff1f49be0bb751b2d25ae6"/><dir name="Tab"><file name="Form.php" hash="ca02b29110a74df7fa13c6377e0621b1"/></dir><file name="Tabs.php" hash="69cab78ea0631d5248ca3a5a412846a4"/></dir><file name="Edit.php" hash="1c1812b4a0e11bc1344f7ec2b910100d"/><file name="Grid.php" hash="35ac5684c25a30ef319423feacba4c26"/></dir><file name="Storelocator.php" hash="0a2ce63f7097ab8372707538a69842a7"/></dir><file name="Index.php" hash="e7a7da34011f86f293b3bb860613f2f4"/></dir><dir name="Helper"><file name="Data.php" hash="0b87ae1bb674b22df79067dc6c8fe2cd"/></dir><dir name="Model"><dir name="Mysql4"><dir name="Storelocator"><file name="Collection.php" hash="63eb3eef688561558300700d61d233a9"/></dir><file name="Storelocator.php" hash="8deb77c0bcad8e84fd0363578f971be7"/></dir><file name="Storelocator.php" hash="90b7ccbfdd3ba71e832c93384c62c7e0"/></dir><dir name="controllers"><dir name="Adminhtml"><file name="StorelocatorController.php" hash="621d2b7164e90ab8a321667a49f9d609"/></dir><file name="IndexController.php" hash="4f71270ca2fb7fc3db2f10f27350509c"/></dir><dir name="etc"><file name="config.xml" hash="3e8d36dcbc9e8057f98bc2f304f9ba51"/></dir><dir name="sql"><dir name="storelocator_setup"><file name="mysql4-install-1.1.1.php" hash="313f386101db38e12f6a6e4baf819c81"/></dir></dir></dir></dir></target><target name="magedesign"><dir name="frontend"><dir name="base"><dir name="default"><dir name="template"><dir name="storelocator"><file name="index.phtml" hash="cff433cf5b6d286fb9e46a415b5d5f03"/></dir></dir><dir name="layout"><file name="storelocator.xml" hash="db01f1e299e94c6a4d633a1d2458f343"/></dir></dir></dir></dir></target><target name="magelocal"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="layout"><file name="storelocator.xml" hash=""/></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Manv_Storelocator.xml" hash="3a47cbe0561d9f23c3f5ab42e2292160"/></dir></target></contents>
16
+ <compatible/>
17
+ <dependencies><required><php><min>5.1.0</min><max>6.0.0</max></php></required></dependencies>
18
+ </package>