/** * Draw all locations * @param $location_id * @param $params * @param $draw */ public static function DrawAllSubLocations($location_id = '', $params = array(), $draw = true) { $tag_name = isset($params['tag_name']) ? $params['tag_name'] : 'l_sub_locaton'; $tag_id = isset($params['tag_id']) ? $params['tag_id'] : 'id_l_sub_locaton'; $selected_value = isset($params['selected_value']) ? $params['selected_value'] : ''; $javascript_event = isset($params['javascript_event']) ? ' ' . $params['javascript_event'] : ''; $output = '<select name="' . $tag_name . '" id="' . $tag_id . '"' . $javascript_event . '>'; $output .= '<option value="">-- ' . _ALL_SUB_LOCATIONS . ' --</option>'; $locations = ListingsSubLocations::GetAllSubLocations($location_id, 'name ASC'); for ($i = 0; $i < $locations[1]; $i++) { if ($selected_value == $locations[0][$i]['id']) { $selected_state = 'selected="selected"'; } else { $selected_state = ''; } $output .= '<option ' . $selected_state . ' value="' . $locations[0][$i]['id'] . '">' . $locations[0][$i]['name'] . '</option>'; } $output .= '</select>'; if ($draw) { echo $output; } else { return $output; } }
/** * Before Edit mode */ public function BeforeDetailsRecord() { // prepare array for sub-location $listing_location_id = (int) $this->result[0][0]['listing_location_id']; $total_sub_locations = ListingsSubLocations::GetAllSubLocations($listing_location_id, 'name ASC'); $arr_sub_locations = array(); foreach ($total_sub_locations[0] as $key => $val) { $arr_sub_locations[$val['id']] = $val['name']; } $this->arrDetailsModeFields['separator_general']['listing_sub_location_id'] = array('title' => _SUB_LOCATION, 'type' => 'enum', 'width' => '', 'source' => $arr_sub_locations, 'required' => true); }