Raveinfosys_Dealer - Version 1.0.0

Version Notes

First release

Download this release

Release Info

Developer Rave Infosys
Extension Raveinfosys_Dealer
Version 1.0.0
Comparing to
See all releases


Version 1.0.0

app/code/community/Raveinfosys/Dealer/Block/Search.php ADDED
@@ -0,0 +1,147 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Raveinfosys_Dealer_Block_Search extends Mage_Core_Block_Template
3
+ {
4
+ /**
5
+ * Set search template for dealer search
6
+ */
7
+
8
+ public function __construct()
9
+ {
10
+ parent::__construct();
11
+ $this->setTemplate('raveinfosys/dealer/search.phtml');
12
+ $this->setCollection($this->getCollectionAll());
13
+ }
14
+
15
+ /**
16
+ * For pagination
17
+ */
18
+
19
+ protected function _prepareLayout() {
20
+ parent::_prepareLayout();
21
+ $pager = $this->getLayout()->createBlock('page/html_pager', 'custom.pager');
22
+ $pager->setAvailableLimit(array(6=>6,12=>12,18=>18,'all'=>'all'));
23
+ $pager->setCollection($this->getCollection());
24
+ $this->setChild('pager', $pager);
25
+ $this->getCollection()->load();
26
+ return $this;
27
+ }
28
+
29
+ public function getPagerHtml()
30
+ {
31
+ return $this->getChildHtml('pager');
32
+ }
33
+
34
+ /**
35
+ * To get form action for delear search
36
+ */
37
+ public function getFormAction()
38
+ {
39
+ return Mage::getUrl('dealer/locator/search');
40
+ }
41
+
42
+ /**
43
+ * To get dealers collection and apply filters
44
+ */
45
+ public function getCollectionAll(){
46
+
47
+ $helper = Mage::helper('raveinfosys_dealer');
48
+ $searchTypeZip = $helper->getSearchTypeZip();
49
+ $searchTypeState = $helper->getSearchTypeState();
50
+ $searchTypeCompany = $helper->getSearchTypeCompany();
51
+ $searchTypeDefault = $helper->getSearchTypeBoxDefault();
52
+
53
+ $searchRequest = $this->getRequest();
54
+ $searchType = $searchRequest->getParam('search_type', false);
55
+ $state = $searchRequest->getParam($searchTypeState, false);
56
+ $company = $searchRequest->getParam($searchTypeCompany, false);
57
+ $zip = $searchRequest->getParam($searchTypeZip, false);
58
+ $radius = $searchRequest->getParam('radius', false);
59
+
60
+ if (isset($radius) && $radius == '0') {
61
+ $radius = 0;
62
+ } else {
63
+ $radius = (int) $radius;
64
+ }
65
+
66
+ Mage::register('dealer_search_request', $searchRequest);
67
+
68
+ if (($searchType == $searchTypeState) && !empty($state)) {
69
+ $customerGroup = Mage::getModel('customer/group');
70
+ $customerGroup->load($helper->getDealersCustomerGroup(), 'customer_group_code');
71
+
72
+ $collection = Mage::getResourceModel('customer/address_collection')
73
+ ->addAttributeToSelect('*')
74
+ ->addAttributeToFilter('use_for_dealer_search',array('eq'=>1))
75
+
76
+ ->joinAttribute('group_id', 'customer/group_id', 'parent_id', null, 'left')
77
+ ->addAttributeToFilter('group_id', array('eq' => $customerGroup->getId()))
78
+ ->joinAttribute('is_active_dealer', 'customer/is_active_dealer', 'parent_id', null, 'left')
79
+ ->addAttributeToFilter('is_active_dealer',array('eq'=>1))
80
+
81
+ ->joinAttribute('email', 'customer/email', 'parent_id', null, 'left')
82
+ ->joinAttribute('website_url', 'customer/website_url', 'parent_id', null, 'left')
83
+
84
+ ->addAttributeToFilter('geo_latitude', array('notnull' => true))
85
+ ->addAttributeToFilter('geo_longitude', array('notnull' => true))
86
+
87
+ ->addAttributeToFilter('region', array('like' => '%' . $state . '%'))
88
+ ->addAttributeToFilter('country_id',array('eq'=>$helper->getCountryCodeToSearch()))
89
+ ->addAttributeToSort('company', 'ASC')
90
+ ->addAttributeToSort('city', 'ASC');
91
+
92
+ } else if (($searchType == $searchTypeCompany) && !empty($company)) {
93
+ $customerGroup = Mage::getModel('customer/group');
94
+ $customerGroup->load($helper->getDealersCustomerGroup(), 'customer_group_code');
95
+
96
+ $collection = Mage::getResourceModel('customer/address_collection')
97
+ ->addAttributeToSelect('*')
98
+ ->addAttributeToFilter('use_for_dealer_search',array('eq'=>1))
99
+
100
+ ->joinAttribute('group_id', 'customer/group_id', 'parent_id', null, 'left')
101
+ ->addAttributeToFilter('group_id', array('eq' => $customerGroup->getId()))
102
+ ->joinAttribute('is_active_dealer', 'customer/is_active_dealer', 'parent_id', null, 'left')
103
+ ->addAttributeToFilter('is_active_dealer',array('eq'=>1))
104
+
105
+ ->joinAttribute('email', 'customer/email', 'parent_id', null, 'left')
106
+ ->joinAttribute('website_url', 'customer/website_url', 'parent_id', null, 'left')
107
+
108
+ ->addAttributeToFilter('country_id',array('eq'=>$helper->getCountryCodeToSearch()))
109
+ ->addAttributeToFilter('geo_latitude', array('notnull' => true))
110
+ ->addAttributeToFilter('geo_longitude', array('notnull' => true))
111
+ ->addAttributeToFilter('company', array('like' => '%' . $company . '%'))
112
+ ->addAttributeToSort('city', 'ASC');
113
+
114
+ } else if (($searchType == $searchTypeZip) && ($radius >= 0)) {
115
+
116
+ /* Fake an address based on the provided ZIP */
117
+ $currentAddress = new Mage_Customer_Model_Address();
118
+ $currentAddress->setPostcode($zip);
119
+ $currentAddress->setCountryId($helper->getCountryCodeToSearch());
120
+ /* get GEO for entire faked address/ZIP */
121
+ $centerCoordinates = $helper->getAddressGeoCoordinates($currentAddress, false);
122
+ if(count($centerCoordinates)){
123
+ $centerLat = $centerCoordinates[0];
124
+ $centerLng = $centerCoordinates[1];
125
+
126
+ $collection = $helper->getNearbyDealersLocations($radius, $centerLat, $centerLng);
127
+ $collection->addAttributeToFilter('country_id',array('eq'=>$helper->getCountryCodeToSearch()));
128
+
129
+ Mage::register('dealer_search_center_lat', $centerLat);
130
+ Mage::register('dealer_search_center_lon', $centerLng);
131
+
132
+ }else{//empty collection
133
+ Mage::register('search_type_default', $searchTypeDefault);
134
+ $collection = Mage::getResourceModel('customer/address_collection')
135
+ ->joinAttribute('group_id', 'customer/group_id', 'parent_id', null, 'left')
136
+ ->addAttributeToFilter('group_id', array('eq' => -1));
137
+ }
138
+ }else{
139
+ Mage::register('search_type_default', $searchTypeDefault);
140
+ $collection = Mage::getResourceModel('customer/address_collection')
141
+ ->joinAttribute('group_id', 'customer/group_id', 'parent_id', null, 'left')
142
+ ->addAttributeToFilter('group_id', array('eq' => -1));
143
+ }
144
+
145
+ return $collection;
146
+ }
147
+ }
app/code/community/Raveinfosys/Dealer/Helper/Data.php ADDED
@@ -0,0 +1,238 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Raveinfosys_Dealer_Helper_Data extends Mage_Core_Helper_Data {
3
+
4
+ const GOOGLE_MAPS_HOST = 'maps.googleapis.com';
5
+ const CONFIG_PATH_DEALERS_CUSTOMER_GROUP = 'raveinfosys_dealer_config/dealers_customer_group/default_dealers_customer_group';
6
+ const CONFIG_PATH_SEARCH_RADIUS_OPTIONS = 'raveinfosys_dealer_config/search/radius_options';
7
+ const CONFIG_PATH_SEARCH_RADIUS_OPTION_DEFAULT = 'raveinfosys_dealer_config/search/default_radius_option';
8
+ const CONFIG_PATH_SEARCH_BOX_SEARCH_TYPE_DEFAULT = 'raveinfosys_dealer_config/search/default_box_search_type';
9
+ const CONFIG_PATH_SEARCH_BY_ZIP = 'raveinfosys_dealer_config/search/by_zip';
10
+ const CONFIG_PATH_SEARCH_BY_STATE = 'raveinfosys_dealer_config/search/by_state';
11
+ const CONFIG_PATH_SEARCH_BY_COMPANY = 'raveinfosys_dealer_config/search/by_company';
12
+ const SEARCH_TYPE_ZIP = 'zip';
13
+ const SEARCH_TYPE_STATE = 'state';
14
+ const SEARCH_TYPE_COMPANY = 'company';
15
+ const SEARCH_CUSTOMER_GROUP = 'Dealer';
16
+ const CONFIG_PATH_DEAFULT_SEARCH_COUNTRY = 'raveinfosys_dealer_config/search/default_country';
17
+
18
+ public function getCountryCodeToSearch(){
19
+ return Mage::getStoreConfig(self::CONFIG_PATH_DEAFULT_SEARCH_COUNTRY);
20
+ }
21
+
22
+ public function getSearchTypeBoxDefault() {
23
+ return Mage::getStoreConfig(self::CONFIG_PATH_SEARCH_BOX_SEARCH_TYPE_DEFAULT);
24
+ }
25
+
26
+ public function getSearchTypeZip() {
27
+ return self::SEARCH_TYPE_ZIP;
28
+ }
29
+
30
+ public function getSearchTypeState() {
31
+ return self::SEARCH_TYPE_STATE;
32
+ }
33
+
34
+ public function getSearchTypeCompany() {
35
+ return self::SEARCH_TYPE_COMPANY;
36
+ }
37
+
38
+ public function getIsSearchByZipEnabled() {
39
+ return Mage::getStoreConfig(self::CONFIG_PATH_SEARCH_BY_ZIP);
40
+ }
41
+
42
+ public function getIsSearchByStateEnabled() {
43
+ return Mage::getStoreConfig(self::CONFIG_PATH_SEARCH_BY_STATE);
44
+ }
45
+
46
+ public function getIsSearchByCompanyEnabled() {
47
+ return Mage::getStoreConfig(self::CONFIG_PATH_SEARCH_BY_COMPANY);
48
+ }
49
+
50
+ public function getDealersCustomerGroup() {
51
+ return self::SEARCH_CUSTOMER_GROUP;
52
+ }
53
+
54
+ public function getSearchRadiusOptions() {
55
+ $options = explode(',', Mage::getStoreConfig(self::CONFIG_PATH_SEARCH_RADIUS_OPTIONS));
56
+ return $options;
57
+ }
58
+
59
+ public function getSearchRadiusOptionDefault() {
60
+ return Mage::getStoreConfig(self::CONFIG_PATH_SEARCH_RADIUS_OPTION_DEFAULT);
61
+ }
62
+
63
+ // To get GeoCordinates of any address
64
+ public function getAddressGeoCoordinates(Mage_Customer_Model_Address $address, $saveCoordinatesToAddress = true) {
65
+
66
+ $coordinates = array();
67
+
68
+ if($saveCoordinatesToAddress){ //request from backend
69
+ $lineAddress = $address->getStreet1() . ', ' . $address->getPostcode() . ' ' . $address->getCity() . ', ' . $address->getCountry();
70
+ }else{ //request from search on frontend
71
+ $componentsStr = 'postal_code:'.$address->getPostcode().'|country:'.$address->getCountry();
72
+ }
73
+
74
+ $client = new Zend_Http_Client();
75
+ $client->setUri('http://' . self::GOOGLE_MAPS_HOST . '/maps/api/geocode/json');
76
+ $client->setMethod(Zend_Http_Client::GET);
77
+ $client->setConfig(array('maxredirects' => 0, 'timeout' => 60));
78
+ if($saveCoordinatesToAddress){
79
+ $client->setParameterGet('address', $lineAddress);
80
+ }else{
81
+ $client->setParameterGet('components', $componentsStr);
82
+ }
83
+ $client->setParameterGet('sensor', 'false');
84
+
85
+ $response = $client->request();
86
+
87
+ if ($response->isSuccessful() && $response->getStatus() == 200) {
88
+ $_response = json_decode($response->getBody());
89
+ $_status = @$_response->status;
90
+
91
+ if ($_status == 'OK') {
92
+ $_location = @$_response->results[0]->geometry->location;
93
+ $_lat = $_location->lat;
94
+ $_lng = $_location->lng;
95
+
96
+ if ($_lat && $_lng) {
97
+
98
+ $coordinates = array($_lat, $_lng);
99
+
100
+ if ($saveCoordinatesToAddress) {
101
+ try {
102
+ if(!$address->getGeoLatitude())
103
+ $address->setGeoLatitude($_lat);
104
+ if(!$address->getGeoLongitude())
105
+ $address->setGeoLongitude($_lng);
106
+ } catch (Exception $e) {
107
+ Mage::logException($e);
108
+ }
109
+ }
110
+ }
111
+ }
112
+ }
113
+ return $coordinates;
114
+ }
115
+
116
+
117
+ /**
118
+ * @return collection of regions for which there are dealers available
119
+ */
120
+ public function getDealerRegions() {
121
+
122
+ $customerGroup = Mage::getModel('customer/group');
123
+ $customerGroup->load($this->getDealersCustomerGroup(), 'customer_group_code');
124
+
125
+ $collection = Mage::getResourceModel('customer/address_collection')
126
+ ->joinAttribute('region', 'customer_address/region', 'entity_id', null, 'left')// Just to use for distinct filter
127
+ ->addAttributeToFilter('use_for_dealer_search',array('eq'=>1))
128
+
129
+ ->joinAttribute('group_id', 'customer/group_id', 'parent_id', null, 'left')
130
+ ->addAttributeToFilter('group_id', array('eq' => $customerGroup->getId()))
131
+ ->joinAttribute('is_active_dealer', 'customer/is_active_dealer', 'parent_id', null, 'left')
132
+ ->addAttributeToFilter('is_active_dealer',array('eq'=>1))
133
+ ->addAttributeToFilter('country_id',array('eq'=>$this->getCountryCodeToSearch()))
134
+ ;
135
+ $collection->getSelect()
136
+ ->reset(Zend_Db_Select::COLUMNS)
137
+ ->columns($this->getAttributeTableAlias().'region.value');
138
+ $collection->getSelect()->distinct();
139
+
140
+ $regions = array();
141
+ foreach ($collection as $region) {
142
+ $_region = trim($region->getValue());
143
+ if (!empty($_region)) {
144
+ $regions[] = $_region;
145
+ }
146
+ }
147
+
148
+ sort($regions);
149
+ return $regions;
150
+ }
151
+
152
+ /**
153
+ * @return collection of companies for which there are dealrds available
154
+ */
155
+ public function getDealerCompanies() {
156
+
157
+ $customerGroup = Mage::getModel('customer/group');
158
+ $customerGroup->load($this->getDealersCustomerGroup(), 'customer_group_code');
159
+
160
+ $collection = Mage::getResourceModel('customer/address_collection')
161
+ ->joinAttribute('company', 'customer_address/company', 'entity_id', null, 'left')// Just to use for distinct filter
162
+ ->addAttributeToFilter('use_for_dealer_search',array('eq'=>1))
163
+
164
+ ->joinAttribute('group_id', 'customer/group_id', 'parent_id', null, 'left')
165
+ ->addAttributeToFilter('group_id', array('eq' => $customerGroup->getId()))
166
+ ->joinAttribute('is_active_dealer', 'customer/is_active_dealer', 'parent_id', null, 'left')
167
+ ->addAttributeToFilter('is_active_dealer',array('eq'=>1))
168
+ ->addAttributeToFilter('country_id',array('eq'=>$this->getCountryCodeToSearch()))
169
+ ;
170
+
171
+ $collection->getSelect()
172
+ ->reset(Zend_Db_Select::COLUMNS)
173
+ ->columns($this->getAttributeTableAlias().'company.value');
174
+ $collection->getSelect()->distinct();
175
+ $companies = array();
176
+
177
+ foreach ($collection as $company) {
178
+ $_company = trim($company->getValue());
179
+ if (!empty($_company)) {
180
+ $companies[] = $_company;
181
+ }
182
+ }
183
+
184
+ sort($companies);
185
+ return $companies;
186
+ }
187
+
188
+ /**
189
+ * Search near by dealer location
190
+ * @return collection for locations for zip/postcode search
191
+ */
192
+ public function getNearbyDealersLocations($radius, $centerLat, $centerLng) {
193
+
194
+ $customerGroup = Mage::getModel('customer/group');
195
+ $customerGroup->load($this->getDealersCustomerGroup(), 'customer_group_code');
196
+
197
+ if (!$customerGroup->getId()) {
198
+ throw new Exception($this->__('Unable to load the customer group.'));
199
+ }
200
+
201
+ $attTableAlias = $this->getAttributeTableAlias();
202
+ $collection = Mage::getResourceModel('customer/address_collection')
203
+ ->addAttributeToSelect('*')
204
+ ->addAttributeToFilter('use_for_dealer_search',array('eq'=>1))
205
+
206
+ ->joinAttribute('group_id', 'customer/group_id', 'parent_id', null, 'left')
207
+ ->addAttributeToFilter('group_id', array('eq' => $customerGroup->getId()))
208
+ ->joinAttribute('is_active_dealer', 'customer/is_active_dealer', 'parent_id', null, 'left')
209
+ ->addAttributeToFilter('is_active_dealer',array('eq'=>1))
210
+
211
+ ->joinAttribute('email', 'customer/email', 'parent_id', null, 'left')
212
+ ->joinAttribute('website_url', 'customer/website_url', 'parent_id', null, 'left')
213
+
214
+ ->addAttributeToFilter('geo_latitude', array('notnull' => true))
215
+ ->addAttributeToFilter('geo_longitude', array('notnull' => true))
216
+ ->addExpressionAttributeToSelect('distance', sprintf("(3959 * acos(cos(radians('%s')) * cos(radians(%sgeo_latitude.value)) * cos(radians(%sgeo_longitude.value) - radians('%s')) + sin(radians('%s')) * sin( radians(%sgeo_latitude.value))))", $centerLat, $attTableAlias, $attTableAlias, $centerLng, $centerLat, $attTableAlias, $radius), array('entity_id'))
217
+ ->addAttributeToSort('distance', 'ASC');
218
+
219
+ if ($radius !== 0) {
220
+ $collection->addFieldToFilter('distance', array('lteq' => $radius));
221
+ }
222
+
223
+ $collection->getSelect()->order('distance ' . Varien_Db_Select::SQL_ASC);
224
+ return $collection;
225
+ }
226
+
227
+ /**
228
+ * get attribute table alias as per the magento version
229
+ */
230
+ public function getAttributeTableAlias(){
231
+ $magentoVersion = Mage::getVersion();
232
+ if (version_compare($magentoVersion, '1.6', '>=')){
233
+ return 'at_';
234
+ } else {
235
+ return '_table_';
236
+ }
237
+ }
238
+ }
app/code/community/Raveinfosys/Dealer/Model/Config/Radius/Options.php ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Raveinfosys_Dealer_Model_Config_Radius_Options
4
+ {
5
+ /* Used for options list on distance radius configuration options */
6
+ public function toOptionArray() {
7
+ return array (
8
+ array ( 'label' => 10, 'value' => 10 ),
9
+ array ( 'label' => 20, 'value' => 20 ),
10
+ array ( 'label' => 50, 'value' => 50 ),
11
+ array ( 'label' => 100,'value' => 100 ),
12
+ array ( 'label' => 200,'value' => 200 ),
13
+ array ( 'label' => 300,'value' => 300 ),
14
+ array ( 'label' => 400,'value' => 400 ),
15
+ array ( 'label' => 500,'value' => 500 ),
16
+ array ( 'label' => 1000,'value' => 1000 ),
17
+ array ( 'label' => 2000,'value' => 2000 )
18
+ );
19
+ }
20
+ }
21
+
app/code/community/Raveinfosys/Dealer/Model/Config/Searchtypes/Options.php ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Raveinfosys_Dealer_Model_Config_Searchtypes_Options
4
+ {
5
+ /* Used for options list on configuration variable */
6
+ public function toOptionArray() {
7
+
8
+ $zipKey = Raveinfosys_Dealer_Helper_Data::SEARCH_TYPE_ZIP;
9
+ $customerGroup[0] = array('value' => $zipKey, 'label' => ucfirst($zipKey));
10
+
11
+ $stateKey = Raveinfosys_Dealer_Helper_Data::SEARCH_TYPE_STATE;
12
+ $customerGroup[1] = array('value' => $stateKey, 'label' => ucfirst($stateKey));
13
+
14
+ $companyKey = Raveinfosys_Dealer_Helper_Data::SEARCH_TYPE_COMPANY;
15
+ $customerGroup[2] = array('value' => $companyKey, 'label' => ucfirst($companyKey));
16
+
17
+ return $customerGroup;
18
+ }
19
+ }
20
+
app/code/community/Raveinfosys/Dealer/Model/Observer.php ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Raveinfosys_Dealer_Model_Observer {
3
+
4
+ /**
5
+ * Save latitude and longitude for address
6
+ */
7
+ public function setLatLongForAddress($observer) {
8
+ Mage::helper('raveinfosys_dealer')
9
+ ->getAddressGeoCoordinates($observer->getEvent()->getCustomerAddress());
10
+ }
11
+ }
app/code/community/Raveinfosys/Dealer/controllers/LocatorController.php ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Raveinfosys_Dealer_LocatorController extends Mage_Core_Controller_Front_Action {
4
+ /**
5
+ * Search for dealer
6
+ */
7
+ public function searchAction() {
8
+ $this->loadLayout();
9
+ $this->renderLayout();
10
+ }
11
+
12
+ /**
13
+ * For map display for individual dealer location
14
+ */
15
+ public function mapAction() {
16
+ $this->loadLayout();
17
+ $this->renderLayout();
18
+ }
19
+ }
app/code/community/Raveinfosys/Dealer/etc/adminhtml.xml ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <acl>
4
+ <resources>
5
+ <admin>
6
+ <children>
7
+ <system>
8
+ <children>
9
+ <config>
10
+ <children>
11
+ <raveinfosys_dealer_config translate="title" module="raveinfosys_dealer">
12
+ <title>Dealer Search Config</title>
13
+ </raveinfosys_dealer_config>
14
+ </children>
15
+ </config>
16
+ </children>
17
+ </system>
18
+ </children>
19
+ </admin>
20
+ </resources>
21
+ </acl>
22
+ </config>
app/code/community/Raveinfosys/Dealer/etc/config.xml ADDED
@@ -0,0 +1,73 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <modules>
4
+ <Raveinfosys_Dealer>
5
+ <version>1.0.0.0</version>
6
+ </Raveinfosys_Dealer>
7
+ </modules>
8
+ <global>
9
+ <models>
10
+ <raveinfosys_dealer>
11
+ <class>Raveinfosys_Dealer_Model</class>
12
+ </raveinfosys_dealer>
13
+ </models>
14
+ <blocks>
15
+ <raveinfosys_dealer>
16
+ <class>Raveinfosys_Dealer_Block</class>
17
+ </raveinfosys_dealer>
18
+ </blocks>
19
+ <helpers>
20
+ <raveinfosys_dealer>
21
+ <class>Raveinfosys_Dealer_Helper</class>
22
+ </raveinfosys_dealer>
23
+ </helpers>
24
+ <resources>
25
+ <raveinfosys_dealer_setup>
26
+ <setup>
27
+ <module>Raveinfosys_Dealer</module>
28
+ </setup>
29
+ </raveinfosys_dealer_setup>
30
+ </resources>
31
+ <events>
32
+ <customer_address_save_before>
33
+ <observers>
34
+ <raveinfosys_dealer_setLatLongForAddress>
35
+ <class>raveinfosys_dealer/observer</class>
36
+ <method>setLatLongForAddress</method>
37
+ </raveinfosys_dealer_setLatLongForAddress>
38
+ </observers>
39
+ </customer_address_save_before>
40
+ </events>
41
+ </global>
42
+ <frontend>
43
+ <routers>
44
+ <raveinfosys_dealer>
45
+ <use>standard</use>
46
+ <args>
47
+ <module>Raveinfosys_Dealer</module>
48
+ <frontName>dealer</frontName>
49
+ </args>
50
+ </raveinfosys_dealer>
51
+ </routers>
52
+ <layout>
53
+ <updates>
54
+ <raveinfosys_dealer>
55
+ <file>raveinfosys_dealer.xml</file>
56
+ </raveinfosys_dealer>
57
+ </updates>
58
+ </layout>
59
+ </frontend>
60
+ <default>
61
+ <raveinfosys_dealer_config>
62
+ <search>
63
+ <by_zip><![CDATA[1]]></by_zip>
64
+ <by_company><![CDATA[1]]></by_company>
65
+ <by_state><![CDATA[1]]></by_state>
66
+ <radius_options><![CDATA[10,20,50,100,200,300,400,500,1000,2000]]></radius_options>
67
+ <default_radius_option><![CDATA[100]]></default_radius_option>
68
+ <default_box_search_type><![CDATA[zip]]></default_box_search_type>
69
+ <default_country><![CDATA[US]]></default_country>
70
+ </search>
71
+ </raveinfosys_dealer_config>
72
+ </default>
73
+ </config>
app/code/community/Raveinfosys/Dealer/etc/system.xml ADDED
@@ -0,0 +1,95 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <tabs><!--creates new tab for raveinfosys-->
4
+ <raveinfosys translate="label" module="raveinfosys_dealer">
5
+ <label>RaveInfosys</label>
6
+ <sort_order>101</sort_order>
7
+ </raveinfosys>
8
+ </tabs>
9
+ <sections>
10
+ <raveinfosys_dealer_config translate="label" module="raveinfosys_dealer">
11
+ <label>Dealer</label>
12
+ <tab>raveinfosys</tab>
13
+ <frontend_type>text</frontend_type>
14
+ <sort_order>2000</sort_order>
15
+ <show_in_default>1</show_in_default>
16
+ <show_in_website>1</show_in_website>
17
+ <show_in_store>1</show_in_store>
18
+ <groups>
19
+ <search translate="label">
20
+ <label>Search Settings</label>
21
+ <frontend_type>text</frontend_type>
22
+ <sort_order>10</sort_order>
23
+ <show_in_default>1</show_in_default>
24
+ <show_in_website>1</show_in_website>
25
+ <show_in_store>0</show_in_store>
26
+ <fields>
27
+ <by_zip translate="label">
28
+ <label>Enable Zip Search</label>
29
+ <frontend_type>select</frontend_type>
30
+ <source_model>adminhtml/system_config_source_yesno</source_model>
31
+ <sort_order>1</sort_order>
32
+ <show_in_default>1</show_in_default>
33
+ <show_in_website>1</show_in_website>
34
+ <show_in_store>0</show_in_store>
35
+ </by_zip>
36
+ <by_state translate="label">
37
+ <label>Enable State Search</label>
38
+ <frontend_type>select</frontend_type>
39
+ <source_model>adminhtml/system_config_source_yesno</source_model>
40
+ <sort_order>2</sort_order>
41
+ <show_in_default>1</show_in_default>
42
+ <show_in_website>1</show_in_website>
43
+ <show_in_store>0</show_in_store>
44
+ </by_state>
45
+ <by_company translate="label">
46
+ <label>Enable Company Search</label>
47
+ <frontend_type>select</frontend_type>
48
+ <source_model>adminhtml/system_config_source_yesno</source_model>
49
+ <sort_order>3</sort_order>
50
+ <show_in_default>1</show_in_default>
51
+ <show_in_website>1</show_in_website>
52
+ <show_in_store>0</show_in_store>
53
+ </by_company>
54
+ <radius_options translate="label" module="raveinfosys_dealer">
55
+ <label>Distance(Radius) Options</label>
56
+ <frontend_type>multiselect</frontend_type>
57
+ <source_model>raveinfosys_dealer/config_radius_options</source_model>
58
+ <sort_order>4</sort_order>
59
+ <show_in_default>1</show_in_default>
60
+ <show_in_website>1</show_in_website>
61
+ <show_in_store>0</show_in_store>
62
+ </radius_options>
63
+ <default_radius_option translate="label" module="raveinfosys_dealer">
64
+ <label>Default Distance(Radius)</label>
65
+ <frontend_type>select</frontend_type>
66
+ <source_model>raveinfosys_dealer/config_radius_options</source_model>
67
+ <sort_order>5</sort_order>
68
+ <show_in_default>1</show_in_default>
69
+ <show_in_website>1</show_in_website>
70
+ <show_in_store>0</show_in_store>
71
+ </default_radius_option>
72
+ <default_box_search_type translate="label" module="raveinfosys_dealer">
73
+ <label>Default Box Search Type</label>
74
+ <frontend_type>select</frontend_type>
75
+ <source_model>raveinfosys_dealer/config_searchtypes_options</source_model>
76
+ <sort_order>6</sort_order>
77
+ <show_in_default>1</show_in_default>
78
+ <show_in_website>1</show_in_website>
79
+ <show_in_store>0</show_in_store>
80
+ </default_box_search_type>
81
+ <default_country translate="label">
82
+ <label>Country For Dealer Search</label>
83
+ <frontend_type>select</frontend_type>
84
+ <source_model>adminhtml/system_config_source_country</source_model>
85
+ <sort_order>7</sort_order>
86
+ <show_in_default>1</show_in_default>
87
+ <show_in_website>1</show_in_website>
88
+ <show_in_store>0</show_in_store>
89
+ </default_country>
90
+ </fields>
91
+ </search>
92
+ </groups>
93
+ </raveinfosys_dealer_config>
94
+ </sections>
95
+ </config>
app/code/community/Raveinfosys/Dealer/sql/raveinfosys_dealer_setup/mysql4-install-1.0.0.0.php ADDED
@@ -0,0 +1,183 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Create customer and customer address attributes
4
+ */
5
+ $installer = $this;
6
+ $installer->startSetup();
7
+
8
+ $setup = Mage::getModel('customer/entity_setup', 'core_setup');
9
+
10
+ $setup->addAttribute('customer_address', 'geo_latitude', array(
11
+ 'type' => 'varchar',
12
+ 'input' => 'text',
13
+ 'visible' => true,
14
+ 'required' => false,
15
+ 'backend_label' => 'Geo Latitude',
16
+ 'label' => 'Geo Latitude',
17
+ 'frontend' => '',
18
+ 'class' => '',
19
+ 'source' => '',
20
+ 'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_WEBSITE,
21
+ 'user_defined' => false,
22
+ 'default' => '',
23
+ 'searchable' => false,
24
+ 'filterable' => false,
25
+ 'comparable' => false,
26
+ 'visible_on_front' => true,
27
+ 'unique' => false,
28
+ 'note' => 'If empty, it will generate automatically',
29
+ ));
30
+
31
+ $setup->addAttribute('customer_address', 'geo_longitude', array(
32
+ 'type' => 'varchar',
33
+ 'input' => 'text',
34
+ 'visible' => true,
35
+ 'required' => false,
36
+ 'backend_label' => 'Geo Longitude',
37
+ 'label' => 'Geo Longitude',
38
+ 'frontend' => '',
39
+ 'class' => '',
40
+ 'source' => '',
41
+ 'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_WEBSITE,
42
+ 'user_defined' => false,
43
+ 'default' => '',
44
+ 'searchable' => false,
45
+ 'filterable' => false,
46
+ 'comparable' => false,
47
+ 'visible_on_front' => true,
48
+ 'unique' => false,
49
+ 'note' => 'If empty, it will generate automatically',
50
+ ));
51
+
52
+ $setup->addAttribute('customer_address', 'use_for_dealer_search', array(
53
+ 'type' => 'int',
54
+ 'input' => 'select',
55
+ 'visible' => true,
56
+ 'required' => false,
57
+ 'backend_label' => 'Use In Dealer Search',
58
+ 'label' => 'Use In Dealer Search',
59
+ 'frontend' => '',
60
+ 'class' => '',
61
+ 'source' => 'eav/entity_attribute_source_boolean',
62
+ 'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_WEBSITE,
63
+ 'user_defined' => false,
64
+ 'default' => 0,
65
+ 'searchable' => false,
66
+ 'filterable' => false,
67
+ 'comparable' => false,
68
+ 'visible_on_front' => true,
69
+ 'unique' => false,
70
+ ));
71
+
72
+ /*
73
+ * Adding additional fields to edit customer admin area.
74
+ */
75
+ $setup->addAttribute('customer', 'website_url', array(
76
+ 'backend_label' => 'Website Url',
77
+ 'label' => 'Dealer Website Url',
78
+ 'type' => 'varchar',
79
+ 'frontend' => '',
80
+ 'input' => 'text',
81
+ 'class' => '',
82
+ 'source' => '',
83
+ 'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_WEBSITE,
84
+ 'visible' => true,
85
+ 'required' => false,
86
+ 'user_defined' => false,
87
+ 'default' => '',
88
+ 'searchable' => false,
89
+ 'filterable' => false,
90
+ 'comparable' => false,
91
+ 'visible_on_front' => true,
92
+ 'unique' => false,
93
+ ));
94
+
95
+ $setup->addAttribute('customer', 'is_active_dealer', array(
96
+ 'backend_label' => 'Is Active Dealer',
97
+ 'label' => 'Is Active Dealer',
98
+ 'type' => 'int',
99
+ 'frontend' => '',
100
+ 'input' => 'select',
101
+ 'class' => '',
102
+ 'source' => 'eav/entity_attribute_source_boolean',
103
+ 'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_WEBSITE,
104
+ 'visible' => true,
105
+ 'required' => false,
106
+ 'user_defined' => false,
107
+ 'default' => 0,
108
+ 'searchable' => false,
109
+ 'filterable' => false,
110
+ 'comparable' => false,
111
+ 'visible_on_front' => true,
112
+ 'unique' => false,
113
+ ));
114
+
115
+ $_config = Mage::getSingleton("eav/config");
116
+
117
+ $website = $_config->getAttribute("customer", "website_url");
118
+ $isActiveDealer = $_config->getAttribute("customer", "is_active_dealer");
119
+
120
+ $geoLatitude = $_config->getAttribute("customer_address", "geo_latitude");
121
+ $geoLongitude = $_config->getAttribute("customer_address", "geo_longitude");
122
+ $useForDealerSearch = $_config->getAttribute("customer_address", "use_for_dealer_search");
123
+
124
+ $used_in_forms = array();
125
+ $used_in_forms[] = "adminhtml_customer";
126
+ $used_in_forms[] = "adminhtml_customer_address";
127
+
128
+ // Customer Address Admin
129
+
130
+ $geoLatitude->setData("used_in_forms", $used_in_forms)
131
+ ->setData("is_used_for_customer_segment", false)
132
+ ->setData("is_system", 0)
133
+ ->setData("is_user_defined", 1)
134
+ ->setData("is_visible", 1)
135
+ ->setData("sort_order", 200);
136
+ $geoLatitude->save();
137
+
138
+ $geoLongitude->setData("used_in_forms", $used_in_forms)
139
+ ->setData("is_used_for_customer_segment", false)
140
+ ->setData("is_system", 0)
141
+ ->setData("is_user_defined", 1)
142
+ ->setData("is_visible", 1)
143
+ ->setData("sort_order", 201);
144
+ $geoLongitude->save();
145
+
146
+ $useForDealerSearch->setData("used_in_forms", $used_in_forms)
147
+ ->setData("is_used_for_customer_segment", false)
148
+ ->setData("is_system", 0)
149
+ ->setData("is_user_defined", 1)
150
+ ->setData("is_visible", 1)
151
+ ->setData("sort_order", 202);
152
+ $useForDealerSearch->save();
153
+
154
+ // Customer Admin
155
+
156
+ $website->setData("used_in_forms", $used_in_forms)
157
+ ->setData("is_used_for_customer_segment", false)
158
+ ->setData("is_system", 0)
159
+ ->setData("is_user_defined", 1)
160
+ ->setData("is_visible", 1)
161
+ ->setData("sort_order", 99);
162
+ $website->save();
163
+
164
+ $isActiveDealer->setData("used_in_forms", $used_in_forms)
165
+ ->setData("is_used_for_customer_segment", false)
166
+ ->setData("is_system", 0)
167
+ ->setData("is_user_defined", 1)
168
+ ->setData("is_visible", 1)
169
+ ->setData("sort_order", 100);
170
+ $isActiveDealer->save();
171
+
172
+ /*
173
+ * Create "Dealer" customer group
174
+ */
175
+ $code = 'Dealer';
176
+ $collection = Mage::getModel('customer/group')->getCollection() //get a list of groups
177
+ ->addFieldToFilter('customer_group_code', $code);// filter by group code
178
+ $group = Mage::getModel('customer/group')->load($collection->getFirstItem()->getId());
179
+ $group->setCode($code); //set the code
180
+ $group->setTaxClassId(3); //set tax class
181
+ $group->save();
182
+
183
+ $installer->endSetup();
app/design/frontend/base/default/layout/raveinfosys_dealer.xml ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+
3
+ <layout version="0.1.0">
4
+ <raveinfosys_dealer_locator_search>
5
+ <reference name="root">
6
+ <action method="setTemplate"><template>page/1column.phtml</template></action>
7
+ </reference>
8
+ <reference name="head">
9
+ <action method="addItem"><type>skin_js</type><name>js/raveinfosys/dealer/chosen.proto.min.js</name></action>
10
+ <action method="addItem"><type>skin_css</type><name>css/raveinfosys/dealer/style.css</name></action>
11
+ </reference>
12
+ <reference name="footer">
13
+ <remove name="raveinfosys_dealer_box"/>
14
+ </reference>
15
+ <reference name="content">
16
+ <block type="raveinfosys_dealer/search" name="raveinfosys_dealer_search" >
17
+ </block>
18
+ </reference>
19
+ </raveinfosys_dealer_locator_search>
20
+ <raveinfosys_dealer_locator_map>
21
+ <reference name="root">
22
+ <action method="setTemplate"><template>page/1column.phtml</template></action>
23
+ </reference>
24
+ <reference name="content">
25
+ <block type="core/template" name="raveinfosys_dealer_map" template="raveinfosys/dealer/map.phtml" />
26
+
27
+ </reference>
28
+ </raveinfosys_dealer_locator_map>
29
+ </layout>
app/design/frontend/base/default/template/raveinfosys/dealer/map.phtml ADDED
@@ -0,0 +1,42 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false"></script>
2
+ <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script>
3
+ <script type="text/javascript">
4
+ function getURLParameter(name) {
5
+ return decodeURIComponent(
6
+ (RegExp(name + '=' + '(.+?)(&|$)').exec(location.search)||[,null])[1]
7
+ );
8
+ }
9
+ $(document).ready(function() {
10
+ var latlng = new google.maps.LatLng(getURLParameter('lat'),getURLParameter('lon'));
11
+ var image = '<?php echo $this->getSkinUrl('images/raveinfosys/dealer/google_maps/marker.png') ?>';
12
+ var options = {
13
+ zoom: 12,
14
+ center: latlng,
15
+ mapTypeId: google.maps.MapTypeId.ROADMAP //SATELLITE
16
+ };
17
+ map = new google.maps.Map(document.getElementById("map_canvas"), options);
18
+ geocoder = new google.maps.Geocoder();
19
+ var infowindow = new google.maps.InfoWindow({
20
+ content: getURLParameter('address')
21
+ });
22
+
23
+ marker = new google.maps.Marker({
24
+ map: map,
25
+ draggable: false,
26
+ position: new google.maps.LatLng(getURLParameter('lat'), getURLParameter('lon')),
27
+ icon: image
28
+ });
29
+ google.maps.event.addListener(marker, 'click', function() {
30
+ infowindow.open(map,marker);
31
+ });
32
+ infowindow.open(map,marker);
33
+ });
34
+ </script>
35
+ <div id="map_canvas"></div><br/>
36
+ <style>
37
+ #map_canvas{width:80%; height:500px; margin:0px auto;}
38
+
39
+ @media only screen and (max-width: 767px) {
40
+ #map_canvas{width:100%; height:200px; margin:0px auto;}
41
+ }
42
+ </style>
app/design/frontend/base/default/template/raveinfosys/dealer/search.phtml ADDED
@@ -0,0 +1,359 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php $_helper = Mage::helper('raveinfosys_dealer') ?>
2
+ <div class="page-title">
3
+ <h1><?php echo $_helper->__('Find a dealer') ?></h1>
4
+ </div>
5
+ <?php
6
+ $_searchTypeZip = $_helper->getSearchTypeZip();
7
+ $_searchTypeState = $_helper->getSearchTypeState();
8
+ $_searchTypeCompany = $_helper->getSearchTypeCompany();
9
+
10
+ $_isSearchByZipEnabled = $_helper->getIsSearchByZipEnabled();
11
+ $_isSearchByStateEnabled = $_helper->getIsSearchByStateEnabled();
12
+ $_isSearchByCompanyEnabled = $_helper->getIsSearchByCompanyEnabled();
13
+
14
+ $_dealers = $this->getCollection();
15
+
16
+ //get all registry paramters
17
+ $_searchRequest = Mage::registry('dealer_search_request');
18
+ $_searchTypeDefault = Mage::registry('search_type_default');
19
+ $_searchType = $_searchRequest->getParam('search_type', false);
20
+
21
+ $_state = $_searchRequest->getParam($_searchTypeState, false);
22
+ $_company = $_searchRequest->getParam($_searchTypeCompany, false);
23
+ $_zip = $_searchRequest->getParam($_searchTypeZip, false);
24
+ $_radioType = 'radio';
25
+ $_hiddenType = 'hidden';
26
+ $_radius = '';
27
+
28
+ if (!$_searchType) {
29
+ if($_searchTypeDefault){
30
+ if(($_searchTypeZip == $_searchTypeDefault && $_isSearchByZipEnabled) ||
31
+ ($_searchTypeState == $_searchTypeDefault && $_isSearchByStateEnabled) ||
32
+ ($_searchTypeCompany == $_searchTypeDefault && $_isSearchByCompanyEnabled)
33
+ ){
34
+ $_searchType = $_searchTypeDefault;
35
+ }else{
36
+ $_searchTypeNotSet = true;
37
+ }
38
+ }
39
+ if($_searchTypeNotSet){
40
+ if ($_isSearchByZipEnabled) {
41
+ $_searchType = $_searchTypeZip;
42
+ } else if ($_isSearchByStateEnabled) {
43
+ $_searchType = $_searchTypeState;
44
+ } else if ($_isSearchByCompanyEnabled) {
45
+ $_searchType = $_searchTypeCompany;
46
+ }
47
+ }
48
+ }else if( // if type set and that type not enabled
49
+ ($_searchTypeZip == $_searchType && !$_isSearchByZipEnabled) ||
50
+ ($_searchTypeState == $_searchType && !$_isSearchByStateEnabled) ||
51
+ ($_searchTypeCompany == $_searchType && !$_isSearchByCompanyEnabled)
52
+ ){
53
+ if ($_isSearchByZipEnabled) {
54
+ $_searchType = $_searchTypeZip;
55
+ } else if ($_isSearchByStateEnabled) {
56
+ $_searchType = $_searchTypeState;
57
+ } else if ($_isSearchByCompanyEnabled) {
58
+ $_searchType = $_searchTypeCompany;
59
+ }
60
+ }
61
+
62
+ if ($_searchType == $_searchTypeZip) {
63
+ $_radius = $_searchRequest->getParam('radius', false);
64
+ }
65
+ if (!$_radius && $_radius !== '0') {
66
+ $_radius = $_helper->getSearchRadiusOptionDefault();
67
+ }
68
+
69
+ ?>
70
+ <div class="dealer_locator_container">
71
+ <form action="<?php echo $this->getFormAction(); ?>" id="dealerLocatorSearchForm" method="get">
72
+ <div class="fieldset">
73
+ <?php if ($_isSearchByZipEnabled) { ?>
74
+ <?php $_zipInputType = ($_isSearchByStateEnabled || $_isSearchByCompanyEnabled) ? $_radioType : $_hiddenType; ?>
75
+ <!--<h2 class="legend"><?php echo $this->__('Find a dealer') ?></h2>-->
76
+ <div class="check_field">
77
+
78
+ <div class="check-search-type">
79
+ <input type="<?php echo $_zipInputType; ?>" name="search_type" id="zip_search" value="<?php echo $_searchTypeZip ?>" <?php if ($_searchType == $_searchTypeZip): ?>checked="true"<?php endif; ?> />
80
+ </div>
81
+ <label for="zip_search"><?php echo $_helper->__('Search by ZIP/Postcode') ?></label>
82
+ </div>
83
+ <?php } ?>
84
+
85
+ <?php if ($_isSearchByStateEnabled) { ?>
86
+ <?php $_stateInputType = ($_isSearchByZipEnabled || $_isSearchByCompanyEnabled) ? $_radioType : $_hiddenType; ?>
87
+ <div class="check_field">
88
+ <div class="check-search-type">
89
+ <input type="<?php echo $_stateInputType; ?>" name="search_type" id="state_search" value="<?php echo $_searchTypeState ?>" <?php if ($_searchType == $_searchTypeState): ?>checked="true"<?php endif; ?> />
90
+ </div>
91
+ <label for="state_search"><?php echo $_helper->__('Search by State') ?></label>
92
+ </div>
93
+ <?php } ?>
94
+
95
+ <?php if ($_isSearchByCompanyEnabled) { ?>
96
+ <?php $_companyInputType = ($_isSearchByZipEnabled || $_isSearchByStateEnabled) ? $_radioType : $_hiddenType; ?>
97
+ <div class="check_field">
98
+ <div class="check-search-type">
99
+ <input type="<?php echo $_companyInputType; ?>" name="search_type" id="company_search" value="<?php echo $_searchTypeCompany ?>" <?php if ($_searchType == $_searchTypeCompany): ?>checked="true"<?php endif; ?> />
100
+ </div>
101
+ <label for="company_search"><?php echo $_helper->__('Search by Company') ?></label>
102
+ </div>
103
+
104
+ <?php } ?>
105
+ <div class="clear"></div>
106
+
107
+
108
+ <?php if ($_isSearchByZipEnabled) { ?>
109
+ <div id="location_searchByZip">
110
+ <ul class="form-list">
111
+ <li class="fields">
112
+ <div class="field">
113
+ <label for="zip" class="required"><em>*</em><?php echo $_helper->__('ZIP/Postcode') ?></label>
114
+ <div class="input-box">
115
+ <input maxlength="20" type="text" name="zip" id="zip" title="<?php echo $_helper->__('ZIP/Postcode') ?>" class="required-entry input-text" value="<?php echo $_zip; ?>"/>
116
+ </div>
117
+ </div>
118
+ <div class="field">
119
+ <label for="radius"><?php echo $_helper->__('Distance in miles') ?></label>
120
+ <div class="input-box">
121
+ <select type="text" name="radius" id="radius" title="<?php echo $_helper->__('Distance radius') ?>" data-placeholder="Choose a Radius..." class="dropdown-select" style="width:350px;" tabindex="2">
122
+ <?php $_options = $_helper->getSearchRadiusOptions(); ?>
123
+ <?php foreach ($_options as $_option): ?>
124
+ <?php $_title = ($_option == '0') ? $_helper->__('Any Distance') : sprintf('%s %s', $_option, $_helper->__('miles')); ?>
125
+ <option value="<?php echo $_option; ?>" <?php if ($_radius == $_option): ?>selected="selected"<?php endif; ?>><?php echo $_title?></option>
126
+ <?php endforeach; ?>
127
+ </select>
128
+ </div>
129
+ </div>
130
+ </li>
131
+ </ul>
132
+ </div>
133
+ <?php } ?>
134
+
135
+ <?php if ($_isSearchByStateEnabled) { ?>
136
+ <div id="location_searchByState" style="display: none;">
137
+ <ul class="form-list">
138
+ <li class="fields">
139
+ <label for="state" class="required"><em>*</em><?php echo $_helper->__('State') ?></label>
140
+ <div class="input-box">
141
+ <select type="text" name="state" id="state" title="<?php echo $_helper->__('State') ?>" data-placeholder="Choose a State..." class="dropdown-select" tabindex="2">
142
+ <?php $regions = $_helper->getDealerRegions(); ?>
143
+ <?php foreach ($regions as $region): ?>
144
+ <option value="<?php echo $region ?>" <?php if ($_state == $region): ?>selected="selected"<?php endif; ?> ><?php echo $region ?></option>
145
+ <?php endforeach; ?>
146
+ </select>
147
+ </div>
148
+ </li>
149
+ </ul>
150
+ </div>
151
+
152
+
153
+ <?php } ?>
154
+
155
+ <?php if ($_isSearchByCompanyEnabled) { ?>
156
+ <div id="location_searchByCompany" style="display: none;">
157
+ <ul class="form-list">
158
+ <li class="fields">
159
+ <label for="company" class="required"><em>*</em><?php echo $_helper->__('Company') ?></label>
160
+ <div class="input-box">
161
+ <select type="text" name="company" id="company" title="<?php echo $_helper->__('Company') ?>" data-placeholder="Choose a Company..." class="dropdown-select" style="width:350px;" tabindex="2" >
162
+ <?php $companies = $_helper->getDealerCompanies(); ?>
163
+ <?php foreach ($companies as $company): ?>
164
+ <option value="<?php echo $company ?>" <?php if ($_company == $company): ?>selected="selected"<?php endif; ?> ><?php echo $company ?></option>
165
+ <?php endforeach; ?>
166
+ </select>
167
+ </div>
168
+ </li>
169
+ </ul>
170
+ </div>
171
+ <?php } ?>
172
+ <div class="clear"></div>
173
+ </div>
174
+ <div class="buttons-set">
175
+ <p class="required"><?php echo $_helper->__('* Required Fields') ?></p>
176
+ <button type="submit" title="<?php echo $_helper->__('Search') ?>" class="button"><span><span><?php echo $_helper->__('Search') ?></span></span></button>
177
+ </div>
178
+ </form>
179
+
180
+ </div>
181
+ <script type="text/javascript">
182
+ //<![CDATA[
183
+ var dealerLocatorSearchForm = new VarienForm('dealerLocatorSearchForm', true);
184
+
185
+
186
+ Event.observe(window, 'load', function() {
187
+
188
+ <?php if ($_isSearchByZipEnabled) { ?>
189
+ $('zip_search').observe('click', function(el) {
190
+ hideZip(0);
191
+ hideState(1);
192
+ hideCompany(1);
193
+ });
194
+ <?php } ?>
195
+
196
+ <?php if ($_isSearchByStateEnabled) { ?>
197
+ $('state_search').observe('click', function(el) {
198
+ hideZip(1);
199
+ hideState(0);
200
+ hideCompany(1);
201
+ });
202
+ <?php } ?>
203
+
204
+ <?php if ($_isSearchByCompanyEnabled) { ?>
205
+ $('company_search').observe('click', function(el) {
206
+ hideZip(1);
207
+ hideState(1);
208
+ hideCompany(0);
209
+ });
210
+ <?php } ?>
211
+ });
212
+
213
+ function hideZip(shouldHide)
214
+ {
215
+ <?php if ($_isSearchByZipEnabled) { ?>hideElement(shouldHide, 'location_searchByZip')<?php } ?>
216
+ }
217
+
218
+ function hideState(shouldHide)
219
+ {
220
+ <?php if ($_isSearchByStateEnabled) { ?>hideElement(shouldHide, 'location_searchByState')<?php } ?>
221
+ }
222
+
223
+ function hideCompany(shouldHide)
224
+ {
225
+ <?php if ($_isSearchByCompanyEnabled) { ?>hideElement(shouldHide, 'location_searchByCompany')<?php } ?>
226
+ }
227
+
228
+ function hideElement(shouldHide, elementName)
229
+ {
230
+ if (shouldHide) {
231
+ $(elementName).hide();
232
+ } else {
233
+ $(elementName).show();
234
+ }
235
+ }
236
+
237
+ function hideAll(shouldHide)
238
+ {
239
+ hideZip(shouldHide);
240
+ hideState(shouldHide);
241
+ hideCompany(shouldHide);
242
+ }
243
+
244
+ hideZip(<?php
245
+ if ($_searchType == $_searchTypeZip) {
246
+ echo '0';
247
+ } else {
248
+ echo '1';
249
+ }
250
+ ?>);
251
+ hideState(<?php
252
+ if ($_searchType == $_searchTypeState) {
253
+ echo '0';
254
+ } else {
255
+ echo '1';
256
+ }
257
+ ?>);
258
+ hideCompany(<?php
259
+ if ($_searchType == $_searchTypeCompany) {
260
+ echo '0';
261
+ } else {
262
+ echo '1';
263
+ }
264
+ ?>);
265
+
266
+ //]]>
267
+ </script>
268
+
269
+ <?php if (sizeof($_dealers) > 0) { ?>
270
+ <div id="searchResultMainContainer">
271
+ <div class="search_results">
272
+ <?php echo $this->getPagerHtml(); ?>
273
+ <div class="result_heading">
274
+ <?php
275
+ if($this->getPagerHtml() == ''){
276
+ echo count($_dealers).$_helper->__(' Record(s) Found');
277
+ }else{
278
+ echo $_helper->__('Search Result');
279
+ }?>
280
+ </div>
281
+
282
+ <?php $i=0; foreach ($_dealers as $dealer): ?>
283
+ <?php
284
+ $_dealerGeoLatitude = $dealer->getGeoLatitude() ? $dealer->getGeoLatitude() : 0;
285
+ $_dealerGeoLongitude = $dealer->getGeoLongitude() ? $dealer->getGeoLongitude() : 0;
286
+ $_dealerCountry = Mage::getModel('directory/country')->loadByCode($dealer->getCountry())->getName();
287
+ if($dealer->getGeoLatitude() && $dealer->getGeoLongitude()){
288
+ $_mapParamStr = 'address='.$dealer->getStreet1().' '.$dealer->getCity().', '.$dealer->getPostcode().', '.$_dealerCountry;
289
+ $_mapParamStr .= '&lat='.$dealer->getGeoLatitude().'&lon='.$dealer->getGeoLongitude();
290
+ $_showMap = true;
291
+ }
292
+ ?>
293
+
294
+
295
+ <div class="result <?php if(++$i%2 == 0) echo ' last'; ?>">
296
+
297
+ <div class="left-col">
298
+ <?php if($dealer->getDistance()): ?>
299
+ <div class="distance">
300
+ <?php echo number_format($dealer->getDistance(), 2, '.', ''); ?><span>miles</span>
301
+ </div>
302
+ <?php endif;?>
303
+ <?php if($_showMap):?>
304
+ <div class="preferred-star">
305
+ <a target="_blank" href="<?php echo Mage::getBaseUrl()."dealer/locator/map?".$_mapParamStr; ?>">
306
+ <img src="<?php echo $this->getSkinUrl('images/raveinfosys/dealer/google_maps/marker.png') ?>">
307
+ </a>
308
+ </div>
309
+ <?php endif;?>
310
+ </div>
311
+ <div class="address">
312
+ <p>
313
+ <strong><?php echo $dealer->getCompany() ?></strong><br>
314
+ <?php echo $dealer->getStreet1() ?><br>
315
+ <?php echo $dealer->getCity() ?>,<?php echo $dealer->getRegion() ?> - <?php echo $dealer->getPostcode() ?><br>
316
+ <?php echo $_dealerCountry;?><br>
317
+ <?php if($dealer->getTelephone()) echo 'P: '.$dealer->getTelephone()?><br>
318
+ <?php if($dealer->getEmail()) echo 'Email: '.$dealer->getEmail()?><br>
319
+ <?php if($dealer->getWebsiteUrl() != ''): ?>
320
+ <a target="_blank" href="http://<?php echo $dealer->getWebsiteUrl() ?>"><?php echo $dealer->getWebsiteUrl() ?></a>
321
+ <?php endif; ?>
322
+ </p>
323
+ </div>
324
+ </div>
325
+
326
+ <?php endforeach; ?>
327
+
328
+ </div>
329
+ </div>
330
+ <?php }else if($_searchRequest->getParam('search_type', false) != ''){ ?>
331
+ <div class="no_result"><?php echo $_helper->__('No dealer found'); ?></div>
332
+ <?php }?>
333
+ <?php $magentoVersion = Mage::getVersion();
334
+ if (version_compare($magentoVersion, '1.6', '>=')):
335
+ ?>
336
+ <script type="text/javascript">
337
+ //<![CDATA[
338
+ document.observe('dom:loaded', function(evt) {
339
+ var select, selects, _i, _len, _results;
340
+ if (Prototype.Browser.IE && (Prototype.BrowserFeatures['Version'] === 6 || Prototype.BrowserFeatures['Version'] === 7)) {
341
+ return;
342
+ }
343
+ selects = $$(".dropdown-select");
344
+ _results = [];
345
+
346
+ for (_i = 0, _len = selects.length; _i < _len; _i++) {
347
+ select = selects[_i];
348
+ _results.push(new Chosen(select));
349
+ }
350
+ deselects = $$(".dropdown-select-deselect");
351
+ for (_i = 0, _len = deselects.length; _i < _len; _i++) {
352
+ select = deselects[_i];
353
+ _results.push(new Chosen(select, {allow_single_deselect: true}));
354
+ }
355
+ return _results;
356
+ });
357
+ //]]>
358
+ </script>
359
+ <?php endif;?>
app/etc/modules/Raveinfosys_Dealer.xml ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <modules>
4
+ <Raveinfosys_Dealer>
5
+ <active>true</active>
6
+ <codePool>community</codePool>
7
+ <depends>
8
+ <Mage_Customer />
9
+ </depends>
10
+ </Raveinfosys_Dealer>
11
+ </modules>
12
+ </config>
package.xml ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <package>
3
+ <name>Raveinfosys_Dealer</name>
4
+ <version>1.0.0</version>
5
+ <stability>stable</stability>
6
+ <license>OSL v3.0</license>
7
+ <channel>community</channel>
8
+ <extends/>
9
+ <summary>Dealer search allows you to search all near by dealer's Stores locations</summary>
10
+ <description>Administrator can Create dealers and manage mutiple location of them using dealer search extension. Users can search for a dealer location by searching by Zip/Postcode, state and company name.&#xD;
11
+ In the admin panel, you can configure display radius/distance ranges and manage the filters to display in frontend.&#xD;
12
+ For each dealer, you can create or modify the contact information and the location details.&#xD;
13
+ Dealer Search extension allows you to search dealer locations.</description>
14
+ <notes>First release</notes>
15
+ <authors><author><name>Raveinfosys</name><user>raveinfo</user><email>magento@raveinfosys.com</email></author></authors>
16
+ <date>2015-01-05</date>
17
+ <time>13:45:53</time>
18
+ <contents><target name="mageetc"><dir name="modules"><file name="Raveinfosys_Dealer.xml" hash="960d22c50c2cc8b3faf847d1721eb757"/></dir></target><target name="magecommunity"><dir name="Raveinfosys"><dir name="Dealer"><dir name="Block"><file name="Search.php" hash="50c110b79949ea552df3f8061c67e6e3"/></dir><dir name="Helper"><file name="Data.php" hash="6331222aed3abdfd2cb90d4b802403c7"/></dir><dir name="Model"><dir name="Config"><dir name="Radius"><file name="Options.php" hash="218cf66a5fed580c5c4f66a1823058bb"/></dir><dir name="Searchtypes"><file name="Options.php" hash="dab761269d612e714f8d2f4db2dfaa9c"/></dir></dir><file name="Observer.php" hash="fac731fbb83b2d7c9a4fcf2c117b5ab0"/></dir><dir name="controllers"><file name="LocatorController.php" hash="155489c637ec8f1f20cb3e37167535d4"/></dir><dir name="etc"><file name="adminhtml.xml" hash="89038f30e6ab64f18e49a2cc1fea5551"/><file name="config.xml" hash="8db00c7c7c2dd69b4466506560d43693"/><file name="system.xml" hash="e58cd76cff4e3b548423d96a190df814"/></dir><dir name="sql"><dir name="raveinfosys_dealer_setup"><file name="mysql4-install-1.0.0.0.php" hash="ae5f9644c13d8282203a2b037fd25c1f"/></dir></dir></dir></dir></target><target name="magedesign"><dir name="frontend"><dir name="base"><dir name="default"><dir name="layout"><file name="raveinfosys_dealer.xml" hash="c934f269337feddc48d1312e3517f418"/></dir><dir name="template"><dir name="raveinfosys"><dir name="dealer"><file name="map.phtml" hash="d3b4393d924816a3c08cae014648b01c"/><file name="search.phtml" hash="636b08792790a4c477d486bb733bdf72"/></dir></dir></dir></dir></dir></dir></target><target name="mageskin"><dir name="frontend"><dir name="base"><dir name="default"><dir name="css"><dir name="raveinfosys"><dir name="dealer"><file name="style.css" hash="db3fb22773e7322b8852f9d2d25f080b"/></dir></dir></dir><dir name="images"><dir name="raveinfosys"><dir name="dealer"><file name="chosen-sprite.png" hash="8e70d120437ffc6a1bf7cebeca292d5c"/><dir name="google_maps"><file name="marker.png" hash="fb8037532ab421c32c621dbff6f4f1cf"/></dir></dir></dir></dir><dir name="js"><dir name="raveinfosys"><dir name="dealer"><file name="chosen.proto.min.js" hash="4bebbd711d9ceec30e3e30cb92550ea3"/></dir></dir></dir></dir></dir></dir></target></contents>
19
+ <compatible/>
20
+ <dependencies><required><php><min>5.2.0</min><max>5.6.3</max></php><package><name/><channel>connect.magentocommerce.com/core</channel><min/><max/></package></required></dependencies>
21
+ </package>
skin/frontend/base/default/css/raveinfosys/dealer/style.css ADDED
@@ -0,0 +1,478 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /* @group Base */
2
+ .dropdown-container {
3
+ font-size: 13px;
4
+ position: relative;
5
+ display: inline-block;
6
+ zoom: 1;
7
+ display: inline;
8
+ }
9
+ .dropdown-container .dropdown-drop {
10
+ background: #fff;
11
+ border: 1px solid #aaa;
12
+ border-top: 0;
13
+ position: absolute;
14
+ top: 35px;
15
+ html> top: 35px;
16
+ left: 0;
17
+ -webkit-box-shadow: 0 4px 5px rgba(0,0,0,.15);
18
+ -moz-box-shadow : 0 4px 5px rgba(0,0,0,.15);
19
+ box-shadow : 0 4px 5px rgba(0,0,0,.15);
20
+ z-index: 1010;
21
+ }
22
+ @-moz-document url-prefix() {
23
+ .dropdown-drop {
24
+ top: 47px !important;
25
+ }
26
+ }
27
+ /*-- for IE --*/
28
+ :root .dropdown-drop {
29
+ top: 47px \0 !important;
30
+ }
31
+
32
+ /* @end */
33
+
34
+ /* @group Single Chosen */
35
+ .dropdown-container-single .dropdown-single {
36
+ background-color: #ffffff;
37
+ border: 1px solid #aaaaaa;
38
+ display: block;
39
+ overflow: hidden;
40
+ white-space: nowrap;
41
+ position: relative;
42
+ height: 35px;
43
+ line-height: 35px;
44
+ padding: 0 0 0 8px;
45
+ color: #444444;
46
+ text-decoration: none;
47
+ }
48
+ .dropdown-container-single .dropdown-default {
49
+ color: #999;
50
+ }
51
+ .dropdown-container-single .dropdown-single span {
52
+ margin-right: 26px;
53
+ display: block;
54
+ overflow: hidden;
55
+ white-space: nowrap;
56
+ -o-text-overflow: ellipsis;
57
+ -ms-text-overflow: ellipsis;
58
+ text-overflow: ellipsis;
59
+ }
60
+ .dropdown-container-single .dropdown-single abbr {
61
+ display: block;
62
+ position: absolute;
63
+ right: 26px;
64
+ top: 6px;
65
+ width: 12px;
66
+ height: 13px;
67
+ font-size: 1px;
68
+ background: url('../../../images/raveinfosys/dealer/chosen-sprite.png') right top no-repeat;
69
+ }
70
+ .dropdown-container-single .dropdown-single abbr:hover {
71
+ background-position: right -11px;
72
+ }
73
+ .dropdown-container-single.dropdown-disabled .dropdown-single abbr:hover {
74
+ background-position: right top;
75
+ }
76
+ .dropdown-container-single .dropdown-single div {
77
+ position: absolute;
78
+ right: 0;
79
+ top: 0;
80
+ display: block;
81
+ height: 100%;
82
+ width: 18px;
83
+ }
84
+ .dropdown-container-single .dropdown-single div b {
85
+ background: url('../../../images/raveinfosys/dealer/chosen-sprite.png') no-repeat 0 5px;
86
+ display: block;
87
+ width: 100%;
88
+ height: 100%;
89
+ border-left:1px solid #aaa;
90
+ }
91
+ .dropdown-container-single .dropdown-search {
92
+ padding: 3px 4px;
93
+ position: relative;
94
+ margin: 0;
95
+ white-space: nowrap;
96
+ z-index: 1010;
97
+ }
98
+ .dropdown-container-single .dropdown-search input {
99
+ background: #fff url('../../../images/raveinfosys/dealer/chosen-sprite.png') no-repeat 100% -22px;
100
+ background: url('../../../images/raveinfosys/dealer/chosen-sprite.png') no-repeat 100% -22px, -webkit-gradient(linear, 0 0, 0 100%, color-stop(1%, #eeeeee), color-stop(15%, #ffffff));
101
+ background: url('../../../images/raveinfosys/dealer/chosen-sprite.png') no-repeat 100% -22px, -webkit-linear-gradient(top, #eeeeee 1%, #ffffff 15%);
102
+ background: url('../../../images/raveinfosys/dealer/chosen-sprite.png') no-repeat 100% -22px, -moz-linear-gradient(top, #eeeeee 1%, #ffffff 15%);
103
+ background: url('../../../images/raveinfosys/dealer/chosen-sprite.png') no-repeat 100% -22px, -o-linear-gradient(top, #eeeeee 1%, #ffffff 15%);
104
+ background: url('../../../images/raveinfosys/dealer/chosen-sprite.png') no-repeat 100% -22px, linear-gradient(#eeeeee 1%, #ffffff 15%);
105
+ margin: 1px 0;
106
+ padding: 4px 20px 4px 5px;
107
+ outline: 0;
108
+ border: 1px solid #aaa;
109
+ font-family: sans-serif;
110
+ font-size: 1em;
111
+ }
112
+ .dropdown-container-single .dropdown-drop {
113
+ -webkit-border-radius: 0 0 4px 4px;
114
+ -moz-border-radius : 0 0 4px 4px;
115
+ border-radius : 0 0 4px 4px;
116
+ -moz-background-clip : padding;
117
+ -webkit-background-clip: padding-box;
118
+ background-clip : padding-box;
119
+ }
120
+ /* @end */
121
+
122
+ .dropdown-container-single-nosearch .dropdown-search input {
123
+ position: absolute;
124
+ left: -9000px;
125
+ }
126
+
127
+ /* @group Multi Chosen */
128
+ .dropdown-container-multi .dropdown-choices {
129
+ background-color: #fff;
130
+ background-image: -webkit-gradient(linear, 0 0, 0 100%, color-stop(1%, #eeeeee), color-stop(15%, #ffffff));
131
+ background-image: -webkit-linear-gradient(top, #eeeeee 1%, #ffffff 15%);
132
+ background-image: -moz-linear-gradient(top, #eeeeee 1%, #ffffff 15%);
133
+ background-image: -o-linear-gradient(top, #eeeeee 1%, #ffffff 15%);
134
+ background-image: linear-gradient(#eeeeee 1%, #ffffff 15%);
135
+ border: 1px solid #aaa;
136
+ margin: 0;
137
+ padding: 0;
138
+ cursor: text;
139
+ overflow: hidden;
140
+ height: auto !important;
141
+ height: 1%;
142
+ position: relative;
143
+ }
144
+ .dropdown-container-multi .dropdown-choices li {
145
+ float: left;
146
+ list-style: none;
147
+ }
148
+ .dropdown-container-multi .dropdown-choices .search-field {
149
+ white-space: nowrap;
150
+ margin: 0;
151
+ padding: 0;
152
+ }
153
+ .dropdown-container-multi .dropdown-choices .search-field input {
154
+ color: #666;
155
+ background: transparent !important;
156
+ border: 0 !important;
157
+ font-family: sans-serif;
158
+ font-size: 100%;
159
+ height: 15px;
160
+ padding: 5px;
161
+ margin: 1px 0;
162
+ outline: 0;
163
+ -webkit-box-shadow: none;
164
+ -moz-box-shadow : none;
165
+ box-shadow : none;
166
+ }
167
+ .dropdown-container-multi .dropdown-choices .search-field .default {
168
+ color: #999;
169
+ }
170
+ .dropdown-container-multi .dropdown-choices .search-choice {
171
+ -webkit-border-radius: 3px;
172
+ -moz-border-radius : 3px;
173
+ border-radius : 3px;
174
+ -moz-background-clip : padding;
175
+ -webkit-background-clip: padding-box;
176
+ background-clip : padding-box;
177
+ background-color: #e4e4e4;
178
+ filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#f4f4f4', endColorstr='#eeeeee', GradientType=0 );
179
+ background-image: -webkit-gradient(linear, 0 0, 0 100%, color-stop(20%, #f4f4f4), color-stop(50%, #f0f0f0), color-stop(52%, #e8e8e8), color-stop(100%, #eeeeee));
180
+ background-image: -webkit-linear-gradient(top, #f4f4f4 20%, #f0f0f0 50%, #e8e8e8 52%, #eeeeee 100%);
181
+ background-image: -moz-linear-gradient(top, #f4f4f4 20%, #f0f0f0 50%, #e8e8e8 52%, #eeeeee 100%);
182
+ background-image: -o-linear-gradient(top, #f4f4f4 20%, #f0f0f0 50%, #e8e8e8 52%, #eeeeee 100%);
183
+ background-image: linear-gradient(#f4f4f4 20%, #f0f0f0 50%, #e8e8e8 52%, #eeeeee 100%);
184
+ -webkit-box-shadow: 0 0 2px #ffffff inset, 0 1px 0 rgba(0,0,0,0.05);
185
+ -moz-box-shadow : 0 0 2px #ffffff inset, 0 1px 0 rgba(0,0,0,0.05);
186
+ box-shadow : 0 0 2px #ffffff inset, 0 1px 0 rgba(0,0,0,0.05);
187
+ color: #333;
188
+ border: 1px solid #aaaaaa;
189
+ line-height: 13px;
190
+ padding: 3px 20px 3px 5px;
191
+ margin: 3px 0 3px 5px;
192
+ position: relative;
193
+ cursor: default;
194
+ }
195
+ .dropdown-container-multi .dropdown-choices .search-choice-focus {
196
+ background: #d4d4d4;
197
+ }
198
+ .dropdown-container-multi .dropdown-choices .search-choice .search-choice-close {
199
+ display: block;
200
+ position: absolute;
201
+ right: 3px;
202
+ top: 4px;
203
+ width: 12px;
204
+ height: 13px;
205
+ font-size: 1px;
206
+ background: url('../../../images/raveinfosys/dealer/chosen-sprite.png') right top no-repeat;
207
+ }
208
+ .dropdown-container-multi .dropdown-choices .search-choice .search-choice-close:hover {
209
+ background-position: right -11px;
210
+ }
211
+ .dropdown-container-multi .dropdown-choices .search-choice-focus .search-choice-close {
212
+ background-position: right -11px;
213
+ }
214
+ /* @end */
215
+
216
+ /* @group Results */
217
+ .dropdown-container .dropdown-results {
218
+ margin: 0 4px 4px 0;
219
+ max-height: 240px;
220
+ padding: 0 0 0 4px;
221
+ position: relative;
222
+ overflow-x: hidden;
223
+ overflow-y: auto;
224
+ -webkit-overflow-scrolling: touch;
225
+ }
226
+ .dropdown-container-multi .dropdown-results {
227
+ margin: -1px 0 0;
228
+ padding: 0;
229
+ }
230
+ .dropdown-container .dropdown-results li {
231
+ display: none;
232
+ line-height: 15px;
233
+ padding: 5px 6px;
234
+ margin: 0;
235
+ list-style: none;
236
+ }
237
+ .dropdown-container .dropdown-results .active-result {
238
+ cursor: pointer;
239
+ display: list-item;
240
+ }
241
+ .dropdown-container .dropdown-results .highlighted {
242
+ background-color: #827664;
243
+ /*filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#3875d7', endColorstr='#2a62bc', GradientType=0 ); */
244
+ /*background-image: -webkit-gradient(linear, 0 0, 0 100%, color-stop(20%, #3875d7), color-stop(90%, #2a62bc));*/
245
+ /*background-image: -webkit-linear-gradient(top, #3875d7 20%, #2a62bc 90%);*/
246
+ /*background-image: -moz-linear-gradient(top, #3875d7 20%, #2a62bc 90%);*/
247
+ /*background-image: -o-linear-gradient(top, #3875d7 20%, #2a62bc 90%);*/
248
+ /*background-image: linear-gradient(#3875d7 20%, #2a62bc 90%);*/
249
+ color: #fff;
250
+ }
251
+ .dropdown-container .dropdown-results li em {
252
+ background: #feffde;
253
+ font-style: normal;
254
+ }
255
+ .dropdown-container .dropdown-results .highlighted em {
256
+ background: transparent;
257
+ }
258
+ .dropdown-container .dropdown-results .no-results {
259
+ background: #f4f4f4;
260
+ display: list-item;
261
+ }
262
+ .dropdown-container .dropdown-results .group-result {
263
+ cursor: default;
264
+ color: #999;
265
+ font-weight: bold;
266
+ }
267
+ .dropdown-container .dropdown-results .group-option {
268
+ padding-left: 15px;
269
+ }
270
+ .dropdown-container-multi .dropdown-drop .result-selected {
271
+ display: none;
272
+ }
273
+ .dropdown-container .dropdown-results-scroll {
274
+ background: white;
275
+ margin: 0 4px;
276
+ position: absolute;
277
+ text-align: center;
278
+ width: 321px; /* This should by dynamic with js */
279
+ z-index: 1;
280
+ }
281
+ .dropdown-container .dropdown-results-scroll span {
282
+ display: inline-block;
283
+ height: 17px;
284
+ text-indent: -5000px;
285
+ width: 9px;
286
+ }
287
+ .dropdown-container .dropdown-results-scroll-down {
288
+ bottom: 0;
289
+ }
290
+ .dropdown-container .dropdown-results-scroll-down span {
291
+ background: url('../../../images/raveinfosys/dealer/chosen-sprite.png') no-repeat -4px -3px;
292
+ }
293
+ .dropdown-container .dropdown-results-scroll-up span {
294
+ background: url('../../../images/raveinfosys/dealer/chosen-sprite.png') no-repeat -22px -3px;
295
+ }
296
+ /* @end */
297
+
298
+ /* @group Active */
299
+ .dropdown-container-active .dropdown-single {
300
+ border: 1px solid #B75925;
301
+ }
302
+ .dropdown-container-active .dropdown-single-with-drop {
303
+ border: 1px solid #aaa;
304
+ -webkit-box-shadow: 0 1px 0 #fff inset;
305
+ -moz-box-shadow : 0 1px 0 #fff inset;
306
+ box-shadow : 0 1px 0 #fff inset;
307
+ background-color: #eee;
308
+ filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#eeeeee', endColorstr='#ffffff', GradientType=0 );
309
+ background-image: -webkit-gradient(linear, 0 0, 0 100%, color-stop(20%, #eeeeee), color-stop(80%, #ffffff));
310
+ background-image: -webkit-linear-gradient(top, #eeeeee 20%, #ffffff 80%);
311
+ background-image: -moz-linear-gradient(top, #eeeeee 20%, #ffffff 80%);
312
+ background-image: -o-linear-gradient(top, #eeeeee 20%, #ffffff 80%);
313
+ background-image: linear-gradient(#eeeeee 20%, #ffffff 80%);
314
+ -webkit-border-bottom-left-radius : 0;
315
+ -webkit-border-bottom-right-radius: 0;
316
+ -moz-border-radius-bottomleft : 0;
317
+ -moz-border-radius-bottomright: 0;
318
+ border-bottom-left-radius : 0;
319
+ border-bottom-right-radius: 0;
320
+ }
321
+ .dropdown-container-active .dropdown-single-with-drop div {
322
+ background: transparent;
323
+ border-left: none;
324
+ }
325
+ .dropdown-container-active .dropdown-single-with-drop div b {
326
+ background-position: -18px 5px;
327
+ }
328
+ .dropdown-container-active .dropdown-choices {
329
+ -webkit-box-shadow: 0 0 5px rgba(0,0,0,.3);
330
+ -moz-box-shadow : 0 0 5px rgba(0,0,0,.3);
331
+ box-shadow : 0 0 5px rgba(0,0,0,.3);
332
+ border: 1px solid #5897fb;
333
+ }
334
+ .dropdown-container-active .dropdown-choices .search-field input {
335
+ color: #111 !important;
336
+ }
337
+ /* @end */
338
+
339
+ /* @group Disabled Support */
340
+ .dropdown-disabled {
341
+ cursor: default;
342
+ opacity:0.5 !important;
343
+ }
344
+ .dropdown-disabled .dropdown-single {
345
+ cursor: default;
346
+ }
347
+ .dropdown-disabled .dropdown-choices .search-choice .search-choice-close {
348
+ cursor: default;
349
+ }
350
+
351
+ /* @group Right to Left */
352
+ .dropdown-rtl { text-align: right; }
353
+ .dropdown-rtl .dropdown-single { padding: 0 8px 0 0; overflow: visible; }
354
+ .dropdown-rtl .dropdown-single span { margin-left: 26px; margin-right: 0; direction: rtl; }
355
+
356
+ .dropdown-rtl .dropdown-single div { left: 3px; right: auto; }
357
+ .dropdown-rtl .dropdown-single abbr {
358
+ left: 26px;
359
+ right: auto;
360
+ }
361
+ .dropdown-rtl .dropdown-choices .search-field input { direction: rtl; }
362
+ .dropdown-rtl .dropdown-choices li { float: right; }
363
+ .dropdown-rtl .dropdown-choices .search-choice { padding: 3px 5px 3px 19px; margin: 3px 5px 3px 0; }
364
+ .dropdown-rtl .dropdown-choices .search-choice .search-choice-close { left: 4px; right: auto; background-position: right top;}
365
+ .dropdown-rtl.dropdown-container-single .dropdown-results { margin: 0 0 4px 4px; padding: 0 4px 0 0; }
366
+ .dropdown-rtl .dropdown-results .group-option { padding-left: 0; padding-right: 15px; }
367
+ .dropdown-rtl.dropdown-container-active .dropdown-single-with-drop div { border-right: none; }
368
+ .dropdown-rtl .dropdown-search input {
369
+ background: #fff url('../../../images/raveinfosys/dealer/chosen-sprite.png') no-repeat -38px -22px;
370
+ background: url('../../../images/raveinfosys/dealer/chosen-sprite.png') no-repeat -38px -22px, -webkit-gradient(linear, 0 0, 0 100%, color-stop(1%, #eeeeee), color-stop(15%, #ffffff));
371
+ background: url('../../../images/raveinfosys/dealer/chosen-sprite.png') no-repeat -38px -22px, -webkit-linear-gradient(top, #eeeeee 1%, #ffffff 15%);
372
+ background: url('../../../images/raveinfosys/dealer/chosen-sprite.png') no-repeat -38px -22px, -moz-linear-gradient(top, #eeeeee 1%, #ffffff 15%);
373
+ background: url('../../../images/raveinfosys/dealer/chosen-sprite.png') no-repeat -38px -22px, -o-linear-gradient(top, #eeeeee 1%, #ffffff 15%);
374
+ background: url('../../../images/raveinfosys/dealer/chosen-sprite.png') no-repeat -38px -22px, linear-gradient(#eeeeee 1%, #ffffff 15%);
375
+ padding: 4px 5px 4px 20px;
376
+ direction: rtl;
377
+ }
378
+ /* @end */
379
+
380
+
381
+
382
+ /* Dealer Page Design */
383
+
384
+ .clear{clear:both;}
385
+ .dealer_locator_container {padding:0 0 20px;}
386
+ .dealer_locator_container h2{}
387
+ .dealer_locator_container .fieldset{}
388
+ .dealer_locator_container .fieldset .check_field{float:left; width:auto; margin:0 20px 0 0;}
389
+ .dealer_locator_container .fieldset .check_field .check-search-type{float:left; margin:0 8px 0 0;}
390
+ .dealer_locator_container .fieldset .check_field label{float:left;}
391
+
392
+ #location_searchByZip .fields, #location_searchByState .fields, #location_searchByCompany .fields{ margin: 20px 20px 0 0;}
393
+ #location_searchByZip .fields .field, #location_searchByState .fields .field, #location_searchByCompany .fields .field{
394
+ float: left; width: auto; margin: 0px 20px 0 0;}
395
+ #location_searchByZip .fields .field .input-box input[type="text"]{height:auto; padding:6px;}
396
+ #location_searchByState{width:40%;}
397
+ #location_searchByCompany{width:40%;}
398
+ #location_searchByZip .field .input-box{width:348px;}
399
+
400
+ #location_searchByState .dropdown-container-single .dropdown-single{width:363px;}
401
+ #location_searchByCompany .dropdown-container-single .dropdown-single{width:348px;}
402
+
403
+
404
+ /*-- SEARCH RESULT --*/
405
+ .search_results .result {
406
+ border: 1px solid #ddd;
407
+ float: left;
408
+ margin: 0 14px 20px 0;
409
+ min-height: 184px;
410
+ width:49%;
411
+ }
412
+ .search_results .last{margin-right:0px;}
413
+ .search_results .result .left-col {
414
+ border-right: 1px solid #ddd;
415
+ float: left;
416
+ height: 188px;
417
+ width: 25%;
418
+ }
419
+ .search_results .result .distance {
420
+ border-bottom: 1px solid #ddd;
421
+ color: #302b2c;
422
+ font-size: 18px;
423
+ /*height: 56px;*/
424
+ padding: 20px 0 10px;
425
+ text-align: center;
426
+ }
427
+ .search_results .result .distance span {
428
+ display: block;
429
+ font-size: 12px;
430
+ }
431
+ .search_results .result .preferred-star {
432
+ padding-top: 35px;
433
+ text-align: center;
434
+ }
435
+ .search_results .result .preferred-star img{
436
+ text-align: center; display:inline;
437
+ }
438
+
439
+
440
+
441
+
442
+ .search_results .result .address {
443
+ /*border-right: 1px solid #929292;*/
444
+ float: left;
445
+ font-size: 14px;
446
+ height: 162px;
447
+ line-height: 23px;
448
+ padding: 26px 0 0 3%;
449
+ width: 70%;
450
+ }
451
+ .search_results .result .map {
452
+ float: left;
453
+ overflow: hidden;
454
+ width: 487px;
455
+ }
456
+ .search_results {
457
+ /* min-height: 500px;*/
458
+ overflow-x: hidden;
459
+ overflow-y: auto;
460
+ margin:20px 0;
461
+ }
462
+ .search_results .result_heading{border-bottom:1px solid #ededed; font-size:18px; text-transform:uppercase; padding:8px 0;
463
+ margin:0 0 15px;}
464
+ /*.footer .block-title{border-top:none;}*/
465
+ .no_result{color:#f00; border:1px solid #ddd; padding:10px; margin:15px 0;}
466
+ #map_canvas{width:80%; height:500px; margin:0px auto;}
467
+
468
+
469
+ @media only screen and (max-width: 767px) {
470
+
471
+ .search_results .result { width: 100%;}
472
+ .search_results .result .distance { font-size: 14px;}
473
+ #location_searchByZip .field .input-box {width: 290px;}
474
+ #location_searchByState .dropdown-container-single .dropdown-single { width: 290px;}
475
+ #location_searchByCompany .dropdown-container-single .dropdown-single { width: 290px;}
476
+
477
+
478
+ }
skin/frontend/base/default/images/raveinfosys/dealer/chosen-sprite.png ADDED
Binary file
skin/frontend/base/default/images/raveinfosys/dealer/google_maps/marker.png ADDED
Binary file
skin/frontend/base/default/js/raveinfosys/dealer/chosen.proto.min.js ADDED
@@ -0,0 +1,2 @@
 
 
1
+ // For Select box inhanced
2
+ (function(){var SelectParser;SelectParser=function(){function SelectParser(){this.options_index=0,this.parsed=[]}return SelectParser.prototype.add_node=function(child){return child.nodeName==="OPTGROUP"?this.add_group(child):this.add_option(child)},SelectParser.prototype.add_group=function(group){var group_position,option,_i,_len,_ref,_results;group_position=this.parsed.length,this.parsed.push({array_index:group_position,group:!0,label:group.label,children:0,disabled:group.disabled}),_ref=group.childNodes,_results=[];for(_i=0,_len=_ref.length;_i<_len;_i++)option=_ref[_i],_results.push(this.add_option(option,group_position,group.disabled));return _results},SelectParser.prototype.add_option=function(option,group_position,group_disabled){if(option.nodeName==="OPTION")return option.text!==""?(group_position!=null&&(this.parsed[group_position].children+=1),this.parsed.push({array_index:this.parsed.length,options_index:this.options_index,value:option.value,text:option.text,html:option.innerHTML,selected:option.selected,disabled:group_disabled===!0?group_disabled:option.disabled,group_array_index:group_position,classes:option.className,style:option.style.cssText})):this.parsed.push({array_index:this.parsed.length,options_index:this.options_index,empty:!0}),this.options_index+=1},SelectParser}(),SelectParser.select_to_array=function(select){var child,parser,_i,_len,_ref;parser=new SelectParser,_ref=select.childNodes;for(_i=0,_len=_ref.length;_i<_len;_i++)child=_ref[_i],parser.add_node(child);return parser.parsed},this.SelectParser=SelectParser}).call(this),function(){var AbstractChosen,root;root=this,AbstractChosen=function(){function AbstractChosen(form_field,options){this.form_field=form_field,this.options=options!=null?options:{},this.set_default_values(),this.is_multiple=this.form_field.multiple,this.set_default_text(),this.setup(),this.set_up_html(),this.register_observers(),this.finish_setup()}return AbstractChosen.prototype.set_default_values=function(){var _this=this;return this.click_test_action=function(evt){return _this.test_active_click(evt)},this.activate_action=function(evt){return _this.activate_field(evt)},this.active_field=!1,this.mouse_on_container=!1,this.results_showing=!1,this.result_highlighted=null,this.result_single_selected=null,this.allow_single_deselect=this.options.allow_single_deselect!=null&&this.form_field.options[0]!=null&&this.form_field.options[0].text===""?this.options.allow_single_deselect:!1,this.disable_search_threshold=this.options.disable_search_threshold||0,this.disable_search=this.options.disable_search||!1,this.search_contains=this.options.search_contains||!1,this.choices=0,this.single_backstroke_delete=this.options.single_backstroke_delete||!1,this.max_selected_options=this.options.max_selected_options||Infinity},AbstractChosen.prototype.set_default_text=function(){return this.form_field.getAttribute("data-placeholder")?this.default_text=this.form_field.getAttribute("data-placeholder"):this.is_multiple?this.default_text=this.options.placeholder_text_multiple||this.options.placeholder_text||"Select Some Options":this.default_text=this.options.placeholder_text_single||this.options.placeholder_text||"Select an Option",this.results_none_found=this.form_field.getAttribute("data-no_results_text")||this.options.no_results_text||"No results match"},AbstractChosen.prototype.mouse_enter=function(){return this.mouse_on_container=!0},AbstractChosen.prototype.mouse_leave=function(){return this.mouse_on_container=!1},AbstractChosen.prototype.input_focus=function(evt){var _this=this;if(!this.active_field)return setTimeout(function(){return _this.container_mousedown()},50)},AbstractChosen.prototype.input_blur=function(evt){var _this=this;if(!this.mouse_on_container)return this.active_field=!1,setTimeout(function(){return _this.blur_test()},100)},AbstractChosen.prototype.result_add_option=function(option){var classes,style;return option.disabled?"":(option.dom_id=this.container_id+"_o_"+option.array_index,classes=option.selected&&this.is_multiple?[]:["active-result"],option.selected&&classes.push("result-selected"),option.group_array_index!=null&&classes.push("group-option"),option.classes!==""&&classes.push(option.classes),style=option.style.cssText!==""?' style="'+option.style+'"':"",'<li id="'+option.dom_id+'" class="'+classes.join(" ")+'"'+style+">"+option.html+"</li>")},AbstractChosen.prototype.results_update_field=function(){return this.is_multiple||this.results_reset_cleanup(),this.result_clear_highlight(),this.result_single_selected=null,this.results_build()},AbstractChosen.prototype.results_toggle=function(){return this.results_showing?this.results_hide():this.results_show()},AbstractChosen.prototype.results_search=function(evt){return this.results_showing?this.winnow_results():this.results_show()},AbstractChosen.prototype.keyup_checker=function(evt){var stroke,_ref;stroke=(_ref=evt.which)!=null?_ref:evt.keyCode,this.search_field_scale();switch(stroke){case 8:if(this.is_multiple&&this.backstroke_length<1&&this.choices>0)return this.keydown_backstroke();if(!this.pending_backstroke)return this.result_clear_highlight(),this.results_search();break;case 13:evt.preventDefault();if(this.results_showing)return this.result_select(evt);break;case 27:return this.results_showing&&this.results_hide(),!0;case 9:case 38:case 40:case 16:case 91:case 17:break;default:return this.results_search()}},AbstractChosen.prototype.generate_field_id=function(){var new_id;return new_id=this.generate_random_id(),this.form_field.id=new_id,new_id},AbstractChosen.prototype.generate_random_char=function(){var chars,newchar,rand;return chars="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ",rand=Math.floor(Math.random()*chars.length),newchar=chars.substring(rand,rand+1)},AbstractChosen}(),root.AbstractChosen=AbstractChosen}.call(this),function(){var Chosen,get_side_border_padding,root,__hasProp=Object.prototype.hasOwnProperty,__extends=function(child,parent){function ctor(){this.constructor=child}for(var key in parent)__hasProp.call(parent,key)&&(child[key]=parent[key]);return ctor.prototype=parent.prototype,child.prototype=new ctor,child.__super__=parent.prototype,child};root=this,Chosen=function(_super){function Chosen(){Chosen.__super__.constructor.apply(this,arguments)}return __extends(Chosen,_super),Chosen.prototype.setup=function(){return this.current_value=this.form_field.value,this.is_rtl=this.form_field.hasClassName("dropdown-rtl")},Chosen.prototype.finish_setup=function(){return this.form_field.addClassName("dropdown-done")},Chosen.prototype.set_default_values=function(){return Chosen.__super__.set_default_values.call(this),this.single_temp=new Template('<a href="javascript:void(0)" class="dropdown-single dropdown-default"><span>#{default}</span><div><b></b></div></a><div class="dropdown-drop" style="left:-9000px;"><div class="dropdown-search"><input type="text" autocomplete="off" /></div><ul class="dropdown-results"></ul></div>'),this.multi_temp=new Template('<ul class="dropdown-choices"><li class="search-field"><input type="text" value="#{default}" class="default" autocomplete="off" style="width:25px;" /></li></ul><div class="dropdown-drop" style="left:-9000px;"><ul class="dropdown-results"></ul></div>'),this.choice_temp=new Template('<li class="search-choice" id="#{id}"><span>#{choice}</span><a href="javascript:void(0)" class="search-choice-close" rel="#{position}"></a></li>'),this.no_results_temp=new Template('<li class="no-results">'+this.results_none_found+' "<span>#{terms}</span>"</li>')},Chosen.prototype.set_up_html=function(){var base_template,container_props,dd_top,dd_width,sf_width;return this.container_id=this.form_field.identify().replace(/[^\w]/g,"_")+"_dropdown",this.f_width=this.form_field.getStyle("width")?parseInt(this.form_field.getStyle("width"),10):this.form_field.getWidth(),container_props={id:this.container_id,"class":"dropdown-container"+(this.is_rtl?" dropdown-rtl":""),style:"width: "+this.f_width+"px"},base_template=this.is_multiple?(new Element("div",container_props)).update(this.multi_temp.evaluate({"default":this.default_text})):(new Element("div",container_props)).update(this.single_temp.evaluate({"default":this.default_text})),this.form_field.hide().insert({after:base_template}),this.container=$(this.container_id),this.container.addClassName("dropdown-container-"+(this.is_multiple?"multi":"single")),this.dropdown=this.container.down("div.dropdown-drop"),dd_top=this.container.getHeight(),dd_width=this.f_width-get_side_border_padding(this.dropdown),this.dropdown.setStyle({width:dd_width+"px",top:dd_top+"px"}),this.search_field=this.container.down("input"),this.search_results=this.container.down("ul.dropdown-results"),this.search_field_scale(),this.search_no_results=this.container.down("li.no-results"),this.is_multiple?(this.search_choices=this.container.down("ul.dropdown-choices"),this.search_container=this.container.down("li.search-field")):(this.search_container=this.container.down("div.dropdown-search"),this.selected_item=this.container.down(".dropdown-single"),sf_width=dd_width-get_side_border_padding(this.search_container)-get_side_border_padding(this.search_field),this.search_field.setStyle({width:sf_width+"px"})),this.results_build(),this.set_tab_index(),this.form_field.fire("liszt:ready",{chosen:this})},Chosen.prototype.register_observers=function(){var _this=this;return this.container.observe("mousedown",function(evt){return _this.container_mousedown(evt)}),this.container.observe("mouseup",function(evt){return _this.container_mouseup(evt)}),this.container.observe("mouseenter",function(evt){return _this.mouse_enter(evt)}),this.container.observe("mouseleave",function(evt){return _this.mouse_leave(evt)}),this.search_results.observe("mouseup",function(evt){return _this.search_results_mouseup(evt)}),this.search_results.observe("mouseover",function(evt){return _this.search_results_mouseover(evt)}),this.search_results.observe("mouseout",function(evt){return _this.search_results_mouseout(evt)}),this.form_field.observe("liszt:updated",function(evt){return _this.results_update_field(evt)}),this.form_field.observe("liszt:activate",function(evt){return _this.activate_field(evt)}),this.form_field.observe("liszt:open",function(evt){return _this.container_mousedown(evt)}),this.search_field.observe("blur",function(evt){return _this.input_blur(evt)}),this.search_field.observe("keyup",function(evt){return _this.keyup_checker(evt)}),this.search_field.observe("keydown",function(evt){return _this.keydown_checker(evt)}),this.is_multiple?(this.search_choices.observe("click",function(evt){return _this.choices_click(evt)}),this.search_field.observe("focus",function(evt){return _this.input_focus(evt)})):this.container.observe("click",function(evt){return evt.preventDefault()})},Chosen.prototype.search_field_disabled=function(){this.is_disabled=this.form_field.disabled;if(this.is_disabled)return this.container.addClassName("dropdown-disabled"),this.search_field.disabled=!0,this.is_multiple||this.selected_item.stopObserving("focus",this.activate_action),this.close_field();this.container.removeClassName("dropdown-disabled"),this.search_field.disabled=!1;if(!this.is_multiple)return this.selected_item.observe("focus",this.activate_action)},Chosen.prototype.container_mousedown=function(evt){var target_closelink;if(!this.is_disabled)return target_closelink=evt!=null?evt.target.hasClassName("search-choice-close"):!1,evt&&evt.type==="mousedown"&&!this.results_showing&&evt.stop(),!this.pending_destroy_click&&!target_closelink?(this.active_field?!this.is_multiple&&evt&&(evt.target===this.selected_item||evt.target.up("a.dropdown-single"))&&this.results_toggle():(this.is_multiple&&this.search_field.clear(),document.observe("click",this.click_test_action),this.results_show()),this.activate_field()):this.pending_destroy_click=!1},Chosen.prototype.container_mouseup=function(evt){if(evt.target.nodeName==="ABBR"&&!this.is_disabled)return this.results_reset(evt)},Chosen.prototype.blur_test=function(evt){if(!this.active_field&&this.container.hasClassName("dropdown-container-active"))return this.close_field()},Chosen.prototype.close_field=function(){return document.stopObserving("click",this.click_test_action),this.is_multiple||(this.selected_item.tabIndex=this.search_field.tabIndex,this.search_field.tabIndex=-1),this.active_field=!1,this.results_hide(),this.container.removeClassName("dropdown-container-active"),this.winnow_results_clear(),this.clear_backstroke(),this.show_search_field_default(),this.search_field_scale()},Chosen.prototype.activate_field=function(){return!this.is_multiple&&!this.active_field&&(this.search_field.tabIndex=this.selected_item.tabIndex,this.selected_item.tabIndex=-1),this.container.addClassName("dropdown-container-active"),this.active_field=!0,this.search_field.value=this.search_field.value,this.search_field.focus()},Chosen.prototype.test_active_click=function(evt){return evt.target.up("#"+this.container_id)?this.active_field=!0:this.close_field()},Chosen.prototype.results_build=function(){var content,data,_i,_len,_ref;this.parsing=!0,this.results_data=root.SelectParser.select_to_array(this.form_field),this.is_multiple&&this.choices>0?(this.search_choices.select("li.search-choice").invoke("remove"),this.choices=0):this.is_multiple||(this.selected_item.addClassName("dropdown-default").down("span").update(this.default_text),this.disable_search||this.form_field.options.length<=this.disable_search_threshold?this.container.addClassName("dropdown-container-single-nosearch"):this.container.removeClassName("dropdown-container-single-nosearch")),content="",_ref=this.results_data;for(_i=0,_len=_ref.length;_i<_len;_i++)data=_ref[_i],data.group?content+=this.result_add_group(data):data.empty||(content+=this.result_add_option(data),data.selected&&this.is_multiple?this.choice_build(data):data.selected&&!this.is_multiple&&(this.selected_item.removeClassName("dropdown-default").down("span").update(data.html),this.allow_single_deselect&&this.single_deselect_control_build()));return this.search_field_disabled(),this.show_search_field_default(),this.search_field_scale(),this.search_results.update(content),this.parsing=!1},Chosen.prototype.result_add_group=function(group){return group.disabled?"":(group.dom_id=this.container_id+"_g_"+group.array_index,'<li id="'+group.dom_id+'" class="group-result">'+group.label.escapeHTML()+"</li>")},Chosen.prototype.result_do_highlight=function(el){var high_bottom,high_top,maxHeight,visible_bottom,visible_top;this.result_clear_highlight(),this.result_highlight=el,this.result_highlight.addClassName("highlighted"),maxHeight=parseInt(this.search_results.getStyle("maxHeight"),10),visible_top=this.search_results.scrollTop,visible_bottom=maxHeight+visible_top,high_top=this.result_highlight.positionedOffset().top,high_bottom=high_top+this.result_highlight.getHeight();if(high_bottom>=visible_bottom)return this.search_results.scrollTop=high_bottom-maxHeight>0?high_bottom-maxHeight:0;if(high_top<visible_top)return this.search_results.scrollTop=high_top},Chosen.prototype.result_clear_highlight=function(){return this.result_highlight&&this.result_highlight.removeClassName("highlighted"),this.result_highlight=null},Chosen.prototype.results_show=function(){var dd_top;if(!this.is_multiple)this.selected_item.addClassName("dropdown-single-with-drop"),this.result_single_selected&&this.result_do_highlight(this.result_single_selected);else if(this.max_selected_options<=this.choices)return this.form_field.fire("liszt:maxselected",{chosen:this}),!1;return dd_top=this.is_multiple?this.container.getHeight():this.container.getHeight()-1,this.form_field.fire("liszt:showing_dropdown",{chosen:this}),this.dropdown.setStyle({top:dd_top+"px",left:0}),this.results_showing=!0,this.search_field.focus(),this.search_field.value=this.search_field.value,this.winnow_results()},Chosen.prototype.results_hide=function(){return this.is_multiple||this.selected_item.removeClassName("dropdown-single-with-drop"),this.result_clear_highlight(),this.form_field.fire("liszt:hiding_dropdown",{chosen:this}),this.dropdown.setStyle({left:"-9000px"}),this.results_showing=!1},Chosen.prototype.set_tab_index=function(el){var ti;if(this.form_field.tabIndex)return ti=this.form_field.tabIndex,this.form_field.tabIndex=-1,this.is_multiple?this.search_field.tabIndex=ti:(this.selected_item.tabIndex=ti,this.search_field.tabIndex=-1)},Chosen.prototype.show_search_field_default=function(){return this.is_multiple&&this.choices<1&&!this.active_field?(this.search_field.value=this.default_text,this.search_field.addClassName("default")):(this.search_field.value="",this.search_field.removeClassName("default"))},Chosen.prototype.search_results_mouseup=function(evt){var target;target=evt.target.hasClassName("active-result")?evt.target:evt.target.up(".active-result");if(target)return this.result_highlight=target,this.result_select(evt)},Chosen.prototype.search_results_mouseover=function(evt){var target;target=evt.target.hasClassName("active-result")?evt.target:evt.target.up(".active-result");if(target)return this.result_do_highlight(target)},Chosen.prototype.search_results_mouseout=function(evt){if(evt.target.hasClassName("active-result")||evt.target.up(".active-result"))return this.result_clear_highlight()},Chosen.prototype.choices_click=function(evt){evt.preventDefault();if(this.active_field&&!evt.target.hasClassName("search-choice")&&!evt.target.up(".search-choice")&&!this.results_showing)return this.results_show()},Chosen.prototype.choice_build=function(item){var choice_id,link,_this=this;return this.is_multiple&&this.max_selected_options<=this.choices?(this.form_field.fire("liszt:maxselected",{chosen:this}),!1):(choice_id=this.container_id+"_c_"+item.array_index,this.choices+=1,this.search_container.insert({before:this.choice_temp.evaluate({id:choice_id,choice:item.html,position:item.array_index})}),link=$(choice_id).down("a"),link.observe("click",function(evt){return _this.choice_destroy_link_click(evt)}))},Chosen.prototype.choice_destroy_link_click=function(evt){evt.preventDefault();if(!this.is_disabled)return this.pending_destroy_click=!0,this.choice_destroy(evt.target)},Chosen.prototype.choice_destroy=function(link){return this.choices-=1,this.show_search_field_default(),this.is_multiple&&this.choices>0&&this.search_field.value.length<1&&this.results_hide(),this.result_deselect(link.readAttribute("rel")),link.up("li").remove()},Chosen.prototype.results_reset=function(){this.form_field.options[0].selected=!0,this.selected_item.down("span").update(this.default_text),this.is_multiple||this.selected_item.addClassName("dropdown-default"),this.show_search_field_default(),this.results_reset_cleanup(),typeof Event.simulate=="function"&&this.form_field.simulate("change");if(this.active_field)return this.results_hide()},Chosen.prototype.results_reset_cleanup=function(){var deselect_trigger;this.current_value=this.form_field.value,deselect_trigger=this.selected_item.down("abbr");if(deselect_trigger)return deselect_trigger.remove()},Chosen.prototype.result_select=function(evt){var high,item,position;if(this.result_highlight)return high=this.result_highlight,this.result_clear_highlight(),this.is_multiple?this.result_deactivate(high):(this.search_results.descendants(".result-selected").invoke("removeClassName","result-selected"),this.selected_item.removeClassName("dropdown-default"),this.result_single_selected=high),high.addClassName("result-selected"),position=high.id.substr(high.id.lastIndexOf("_")+1),item=this.results_data[position],item.selected=!0,this.form_field.options[item.options_index].selected=!0,this.is_multiple?this.choice_build(item):(this.selected_item.down("span").update(item.html),this.allow_single_deselect&&this.single_deselect_control_build()),(!evt.metaKey||!this.is_multiple)&&this.results_hide(),this.search_field.value="",typeof Event.simulate=="function"&&(this.is_multiple||this.form_field.value!==this.current_value)&&this.form_field.simulate("change"),this.current_value=this.form_field.value,this.search_field_scale()},Chosen.prototype.result_activate=function(el){return el.addClassName("active-result")},Chosen.prototype.result_deactivate=function(el){return el.removeClassName("active-result")},Chosen.prototype.result_deselect=function(pos){var result,result_data;return result_data=this.results_data[pos],result_data.selected=!1,this.form_field.options[result_data.options_index].selected=!1,result=$(this.container_id+"_o_"+pos),result.removeClassName("result-selected").addClassName("active-result").show(),this.result_clear_highlight(),this.winnow_results(),typeof Event.simulate=="function"&&this.form_field.simulate("change"),this.search_field_scale()},Chosen.prototype.single_deselect_control_build=function(){if(this.allow_single_deselect&&!this.selected_item.down("abbr"))return this.selected_item.down("span").insert({after:'<abbr class="search-choice-close"></abbr>'})},Chosen.prototype.winnow_results=function(){var found,option,part,parts,regex,regexAnchor,result_id,results,searchText,startpos,text,zregex,_i,_j,_len,_len2,_ref;this.no_results_clear(),results=0,searchText=this.search_field.value===this.default_text?"":this.search_field.value.strip().escapeHTML(),regexAnchor=this.search_contains?"":"^",regex=new RegExp(regexAnchor+searchText.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),"i"),zregex=new RegExp(searchText.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),"i"),_ref=this.results_data;for(_i=0,_len=_ref.length;_i<_len;_i++){option=_ref[_i];if(!option.disabled&&!option.empty)if(option.group)$(option.dom_id).hide();else if(!this.is_multiple||!option.selected){found=!1,result_id=option.dom_id;if(regex.test(option.html))found=!0,results+=1;else if(option.html.indexOf(" ")>=0||option.html.indexOf("[")===0){parts=option.html.replace(/\[|\]/g,"").split(" ");if(parts.length)for(_j=0,_len2=parts.length;_j<_len2;_j++)part=parts[_j],regex.test(part)&&(found=!0,results+=1)}found?(searchText.length?(startpos=option.html.search(zregex),text=option.html.substr(0,startpos+searchText.length)+"</em>"+option.html.substr(startpos+searchText.length),text=text.substr(0,startpos)+"<em>"+text.substr(startpos)):text=option.html,$(result_id).innerHTML!==text&&$(result_id).update(text),this.result_activate($(result_id)),option.group_array_index!=null&&$(this.results_data[option.group_array_index].dom_id).setStyle({display:"list-item"})):($(result_id)===this.result_highlight&&this.result_clear_highlight(),this.result_deactivate($(result_id)))}}return results<1&&searchText.length?this.no_results(searchText):this.winnow_results_set_highlight()},Chosen.prototype.winnow_results_clear=function(){var li,lis,_i,_len,_results;this.search_field.clear(),lis=this.search_results.select("li"),_results=[];for(_i=0,_len=lis.length;_i<_len;_i++)li=lis[_i],li.hasClassName("group-result")?_results.push(li.show()):!this.is_multiple||!li.hasClassName("result-selected")?_results.push(this.result_activate(li)):_results.push(void 0);return _results},Chosen.prototype.winnow_results_set_highlight=function(){var do_high;if(!this.result_highlight){this.is_multiple||(do_high=this.search_results.down(".result-selected.active-result")),do_high==null&&(do_high=this.search_results.down(".active-result"));if(do_high!=null)return this.result_do_highlight(do_high)}},Chosen.prototype.no_results=function(terms){return this.search_results.insert(this.no_results_temp.evaluate({terms:terms}))},Chosen.prototype.no_results_clear=function(){var nr,_results;nr=null,_results=[];while(nr=this.search_results.down(".no-results"))_results.push(nr.remove());return _results},Chosen.prototype.keydown_arrow=function(){var actives,nexts,sibs;actives=this.search_results.select("li.active-result");if(actives.length){this.result_highlight?this.results_showing&&(sibs=this.result_highlight.nextSiblings(),nexts=sibs.intersect(actives),nexts.length&&this.result_do_highlight(nexts.first())):this.result_do_highlight(actives.first());if(!this.results_showing)return this.results_show()}},Chosen.prototype.keyup_arrow=function(){var actives,prevs,sibs;if(!this.results_showing&&!this.is_multiple)return this.results_show();if(this.result_highlight)return sibs=this.result_highlight.previousSiblings(),actives=this.search_results.select("li.active-result"),prevs=sibs.intersect(actives),prevs.length?this.result_do_highlight(prevs.first()):(this.choices>0&&this.results_hide(),this.result_clear_highlight())},Chosen.prototype.keydown_backstroke=function(){return this.pending_backstroke?(this.choice_destroy(this.pending_backstroke.down("a")),this.clear_backstroke()):(this.pending_backstroke=this.search_container.siblings("li.search-choice").last(),this.single_backstroke_delete?this.keydown_backstroke():this.pending_backstroke.addClassName("search-choice-focus"))},Chosen.prototype.clear_backstroke=function(){return this.pending_backstroke&&this.pending_backstroke.removeClassName("search-choice-focus"),this.pending_backstroke=null},Chosen.prototype.keydown_checker=function(evt){var stroke,_ref;stroke=(_ref=evt.which)!=null?_ref:evt.keyCode,this.search_field_scale(),stroke!==8&&this.pending_backstroke&&this.clear_backstroke();switch(stroke){case 8:this.backstroke_length=this.search_field.value.length;break;case 9:this.results_showing&&!this.is_multiple&&this.result_select(evt),this.mouse_on_container=!1;break;case 13:evt.preventDefault();break;case 38:evt.preventDefault(),this.keyup_arrow();break;case 40:this.keydown_arrow()}},Chosen.prototype.search_field_scale=function(){var dd_top,div,h,style,style_block,styles,w,_i,_len;if(this.is_multiple){h=0,w=0,style_block="position:absolute; left: -1000px; top: -1000px; display:none;",styles=["font-size","font-style","font-weight","font-family","line-height","text-transform","letter-spacing"];for(_i=0,_len=styles.length;_i<_len;_i++)style=styles[_i],style_block+=style+":"+this.search_field.getStyle(style)+";";return div=(new Element("div",{style:style_block})).update(this.search_field.value.escapeHTML()),document.body.appendChild(div),w=Element.measure(div,"width")+25,div.remove(),w>this.f_width-10&&(w=this.f_width-10),this.search_field.setStyle({width:w+"px"}),dd_top=this.container.getHeight(),this.dropdown.setStyle({top:dd_top+"px"})}},Chosen}(AbstractChosen),root.Chosen=Chosen,Prototype.Browser.IE&&/MSIE (\d+\.\d+);/.test(navigator.userAgent)&&(Prototype.BrowserFeatures.Version=new Number(RegExp.$1)),get_side_border_padding=function(elmt){var layout,side_border_padding;return layout=new Element.Layout(elmt),side_border_padding=layout.get("border-left")+layout.get("border-right")+layout.get("padding-left")+layout.get("padding-right")},root.get_side_border_padding=get_side_border_padding}.call(this);