Current File : /home/giriqfky/public_html/Barga/application/helpers//drop_down_helper.php
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
function initDropDown($name, $id, $default_value = '', $attr = array()){
$html = '<select class="form-control" id="'.$id.'" name="'.$name.'"' ;
if(is_array($attr) && count($attr)){
foreach($attr as $key=>$val) $html .= ' '.$key . '="'.$val.'" ';
}
$html .= '><option value="">'.$default_value.'</option>';
return $html;
}
function printCountryDropdown($name, $id, $selected_ids = array(), $attr = array(), $status_chk = TRUE)
{
$CI = & get_instance();
$CI->load->model('Base_model', 'BaseModel');
$countryRs = $CI->BaseModel->CountryDropdownList($status_chk);
$html = initDropDown($name, $id, 'Select Country', $attr);
if($countryRs->num_rows()){
foreach($countryRs->result() as $country){
$sel = in_array($country->country_id,$selected_ids) ? "selected" : "";
$html .= '<option value="'.$country->country_id.'"'.$sel.'>'.$country->country_name.'</option>';
}
}
$html .= '</select>';
return $html;
}
function printStateDropdown($name, $id, $selected_ids = array(), $attr = array(), $country_id = 0)
{
$CI = & get_instance();
$CI->load->model('Base_model', 'BaseModel');
$state_rs = $CI->BaseModel->StateDropdownList($country_id);
$html = initDropDown($name, $id, 'Select State', $attr);
if($state_rs->num_rows()){
foreach($state_rs->result() as $state){
$sel = in_array($state->state_id,$selected_ids) ? "selected" : "";
$html .= '<option value="'.$state->state_id.'"'.$sel.'>'.$state->state_name.'</option>';
}
}
$html .= '</select>';
return $html;
}
function printCityDropdown($name, $id, $selected_ids = array(), $attr = array(), $state_id = 0)
{
$CI = & get_instance();
$CI->load->model('Base_model', 'BaseModel');
$city_rs = $CI->Base_model->CityDropdownList($state_id);
$html = initDropDown($name, $id, 'Select City', $attr);
if($city_rs->num_rows()){
foreach($city_rs->result() as $city){
$sel = in_array($city->city_id,$selected_ids) ? "selected" : "";
$html .= '<option value="'.$city->city_id.'"'.$sel.'>'.$city->city_name.'</option>';
}
}
$html .= '</select>';
return $html;
}