/** * Defines services filter form */ function storelocator_app_block_filter_services_form($form, &$form_state, $language) { $services = array(); if (isset($_POST['services-overlay'])) { $services[0] = $_POST['services-overlay']; if ($services[0] == '-1') { $services = array(); } } // Get services list $TYPE_FILTER = NULL; // NULL means we don't want to filter on the service type $SEARCH_FILTER = 1; // 1 means we look for services tagged as searchable $services_terms = storelocator_app_ws_getservices_list($TYPE_FILTER, $SEARCH_FILTER, $language); $services_options = array(); if ($services_terms != null) { foreach ($services_terms as $service) { if ($service['carrefour_service_code'] == 'drive') { $services_options[$service['carrefour_service_code']] = $service['name']; break; } } foreach ($services_terms as $service) { if ($service['carrefour_service_code'] != 'drive') { $services_options[$service['carrefour_service_code']] = $service['name']; } } $total_options = count($services_options); $form['filter_services'] = array('#type' => 'item', '#title' => t('Services'), '#weight' => 7); $form['services'] = array('#type' => 'checkboxes', '#default_value' => $services, '#options' => $services_options, '#required' => FALSE, '#weight' => 8, '#attributes' => array('onclick' => 'addFilters(this,"1")'), '#prefix' => '<div class="filter-services">', '#suffix' => '</div>'); }
function storelocator_app_block_overlay_store_form($form, &$form_state, $language) { $default_address = t('Enter a zip code or a city', array(), $language); $form['address-overlay'] = array('#type' => 'textfield', '#title' => t('Enter your zip code', array(), $language) . ' : ', '#default_value' => $default_address, '#size' => 30, '#maxlength' => 50, '#weight' => 1, '#attributes' => array('onfocus' => 'if(this.value == \'' . $default_address . '\') this.value=\'\'', 'onkeypress' => 'if (event.keyCode!=13) return;')); // Get typology list $typologies_terms = storelocator_app_ws_gettaxo_byname('store_typology', $language); $typologies_options = array(); if (!empty($typologies_terms)) { foreach ($typologies_terms as $term) { $typo_img = ''; if (isset($term['field_picto']) && $term['field_picto'] != null) { $typo_img = '<img src="' . $term['field_picto'][0] . '"/> '; } $typologies_options[$term['tid']] = $typo_img . t($term['name']); } } $form['typology-overlay'] = array('#type' => 'checkboxes', '#title' => t('Select a store type', array(), $language) . ' : ', '#options' => $typologies_options, '#required' => FALSE, '#weight' => 2, '#prefix' => '<hr/>'); // Get services list $services_terms = storelocator_app_ws_getservices_list(0, 1); $services_options = array(); $services_options[-1] = t('All services', array(), $language); if ($services_terms != null) { foreach ($services_terms as $service) { $services_options[$service['carrefour_service_code']] = $service['name']; } $form['services-overlay'] = array('#type' => 'select', '#title' => t('Choose a service', array(), $language) . ' : ', '#options' => $services_options, '#required' => FALSE, '#weight' => 3, '#prefix' => '<hr/>'); } $form['submit-overlay'] = array('#type' => 'submit', '#value' => t('Find a store'), '#weight' => 4, '#attributes' => array(), '#prefix' => '<hr/><div class="block-submit"><div class="left">', '#suffix' => ' </div><div class="right">' . l(t('More criteria >', array(), $language), 'store', array()) . '</div></div>'); $form['#attributes']['onsubmit'] = 'return checkAddress("edit-address-overlay",\'' . $default_address . '\');'; $form['#action'] = url(t('store')); return $form; }