} break; case 'save_group': $group_name = $_REQUEST['nam']; $group_pages = json_decode(stripslashes($_REQUEST['pag'])); $group_id = $_REQUEST['group_id']; if (empty($group_id)) { SaveGroup($group_name, $group_pages); } else { ClearForUpdate($group_id); UpdateGroup($group_id, $group_pages, $group_name); } break; case 'disable': $group_id = $_REQUEST['id']; DisableGroup($group_id); break; default: $error = 'Action is Null'; } $data['error'] = $error; echo json_encode($data); /* ****************************** * Workers Functions * ****************************** */ function SaveGroup($group_name, $group_pages) { mysql_query("INSERT\tINTO `group`\r\n\t\t\t\t\t\t(`group`.`name`)\r\n\t\t\t\tVALUES\r\n\t\t\t\t\t\t('{$group_name}')"); $group_id = mysql_insert_id(); $parrentaray = array();
for ($i = 0; $i < count($jora); $i++) { $name_a = $jora[$i][name]; $quest_id_a = $jora[$i][quest_id]; $notes_a = $jora[$i][notes]; $qvota_a = $jora[$i][qvota]; $scenar_id_a = $jora[$i][scenar_id]; $product_id_a = $jora[$i][product_id]; mysql_query("INSERT\tINTO `shabloni`\r\n\t\t\t\t\t\t(`name`, `quest_id`, `notes`, `scenar_id`, `qvota`, `product_id`)\r\n\t\t\t\t\t\t\tVALUES\r\n\t\t\t\t\t\t('{$name_a}','{$quest_id_a}','{$notes_a}','{$scenar_id_a}','{$qvota_a}', '{$product_id_a}')"); } mysql_query("DELETE FROM tmp_shabloni\r\n\t\t\t\t\t"); break; case 'disable': $group_id = $_REQUEST['id']; $delete = mysql_fetch_assoc(mysql_query("SELECT `name`\r\n\t\t\t\t\t\t\t\t\t\t \tFROM `shabloni`\r\n\t\t\t\t\t\t\t\t\t\t\t\tWHERE `id` = {$group_id}")); $delete_row = $delete['name']; DisableGroup($delete_row); break; case 'disable_prod': $id_del_prod = $_REQUEST['id_del_prod']; mysql_query("DELETE FROM shabloni\r\n WHERE `id` = '{$id_del_prod}';"); break; case 'get_product_info': $name = $_REQUEST[name]; $res = GetProductInfo($name); if (!$res) { $error = 'პროდუქტი ვერ მოიძებნა!'; } else { $data = array('genre' => $res['genre'], 'category' => $res['category'], 'description' => $res['description'], 'price' => $res['price'], 'id' => $res['id']); } break; default: