function addOptionFood() { $id = (int) Url::get('id'); $fid = (int) Url::get('fid'); $group_name = Url::get('group_name'); $group_name_en = Url::get('group_name_en'); $group_alias = Url::get('group_alias'); $opt_desc = Url::get('opt_desc'); $opt_desc_en = Url::get('opt_desc_en'); $opt_price = Url::get('opt_price'); $opt_type = Url::get('opt_type'); $opt_enable = Url::get('opt_enable'); if (empty($group_name)) { $group_name = 'Lựa chọn'; } if (empty($group_alias)) { if (!empty($group_name)) { $group_alias = strtolower(EClassApi::safe_title($group_name)); } } else { $group_alias = strtolower(EClassApi::safe_title($group_alias)); } $num_item = count($opt_desc); if ($num_item > 0) { for ($index = 0; $index < $num_item; $index++) { if (empty($opt_desc[$index]) || empty($opt_desc_en[$index])) { continue; } if (intval($opt_type[$index]) == 0 && strtoupper($opt_desc_en[$index]) != 'YES' && strtoupper($opt_desc_en[$index]) != 'NO') { continue; } if (!isset($opt_enable[$index])) { $opt_enable[$index] = 0; } else { $opt_enable[$index] = 1; } $option = array('fid' => $id, 'description' => $opt_desc[$index], 'description_en' => $opt_desc_en[$index], 'group_name' => $group_name, 'group_name_en' => $group_name_en, 'group_alias' => $group_alias, 'type' => intval($opt_type[$index]), 'price' => intval($opt_price[$index]), 'enable' => intval($opt_enable[$index])); DB::insert('food_option', $option); if (MEMCACHE_ON) { $r = mysql_fetch_assoc(DB::query("SELECT * FROM food_res WHERE id=" . $fid)); eb_memcache::do_remove('supplier_food_' . $r['rid']); } } } // Get Food Options $query = DB::query('SELECT * FROM food_option WHERE fid = ' . $id); $list_option = array(); $count = 0; while ($row = mysql_fetch_assoc($query)) { $count++; $row['price'] = EClassApi::numberFormat($row['price']); $list_option[$row['group_name']][] = $row; } mysql_free_result($query); // Get Food Item $query = DB::query('SELECT * FROM food_res fr INNER JOIN food f ON fr.fid = f.id AND f.id = ' . $id); $f = mysql_fetch_assoc($query); $f['food_options'] = $list_option; mysql_free_result($query); // Update Cached Version Restaurant::update_cached_version($fid); global $display; $display->add('f', $f); $display->add('id', $id); $display->output('AdminRestaurant/FoodOptions'); exit; }