public function list_user() { $this->load->helper('build_data'); $recipes = $this->db->query('CALL GetAllUser()'); $recipes = buildDataAutocomplete($recipes, 'UserID', 'UserName', 'UserPhoto'); echo json_encode($recipes); }
public function callDefaultData($type = 'search', $with_sort = false) { $food_types = $this->db->query('CALL GetAllFoodType()'); $food_types = buildDataDropdown($food_types, 'FoodTypeID', 'FoodTypeName'); $cuisines = $this->db->query('CALL GetAllCuisine()'); $cuisines = buildDataDropdown($cuisines, 'CuisineID', 'CuisineName'); $food_process = array(); // For translation purpose, we will hardcode Food process from db if ($this->site_lang == 'indonesian') { $food_process = array(7 => lang('grilled'), 1 => lang('fried'), 3 => lang('steamed'), 2 => lang('baked'), 5 => lang('boiled'), 6 => lang('not_cooked'), 4 => lang('stir_fry')); } else { if ($this->site_lang == 'english') { $food_process = array(2 => lang('baked'), 5 => lang('boiled'), 1 => lang('fried'), 7 => lang('grilled'), 6 => lang('not_cooked'), 3 => lang('steamed'), 4 => lang('stir_fry')); } } $price_ranges = array(); $estimation_peoples = array(); $measure_sizes = array(); $compositions = array(); $sorts = array(); if ($type == 'create') { // $food_process = $this->db->query('CALL GetAllFoodProcess()'); // $food_process = buildDataDropdown($food_process, 'FoodProcessID', 'FoodProcessName'); $price_ranges = $this->db->query('CALL GetAllPriceRange()'); $price_ranges = buildDataDropdown($price_ranges, 'PriceRangeID', 'PriceRangeName'); $estimation_peoples = $this->db->query('CALL GetAllEstPeople()'); $estimation_peoples = buildDataDropdown($estimation_peoples, 'EstPeopleID', 'EstPeopleName'); // Add word 'People', need to do it here for translation purpose $lengthEP = count($estimation_peoples); for ($n = 1; $n <= $lengthEP; $n++) { $estimation_peoples[$n] = sprintf('%s %s', $estimation_peoples[$n], $this->lang->line('people')); } $measure_sizes = $this->db->query('CALL GetAllMeasureSize()'); $measure_sizes = buildDataDropdown($measure_sizes, 'MeasureSizeID', 'MeasureSizeName'); $compositions = $this->db->query('CALL GetAllComposition()'); $compositions = buildDataAutocomplete($compositions, 'CompositionID', 'CompositionName'); } if (!empty($with_sort)) { $sorts = array(0 => $this->lang->line('alphabet'), 1 => $this->lang->line('latest_recipe'), 2 => $this->lang->line('popular_recipe')); } $this->load->vars(array('food_types' => $food_types, 'cuisines' => $cuisines, 'food_process' => $food_process, 'price_ranges' => $price_ranges, 'estimation_peoples' => $estimation_peoples, 'measure_sizes' => $measure_sizes, 'compositions' => json_encode($compositions), 'sorts' => $sorts)); }