= 1 && $cpage <= $maxpage)) { $cpage = 1; } $limit = ($cpage - 1) * $maxperpage; $responseStr = ''; $query = "SELECT * FROM pr_parameters".$addquery." LIMIT $limit, $maxperpage"; if ($result = $conn->query($query)) { while ($c_pr_parameters = $result->fetch_assoc()) { if ($responseStr != "") { $responseStr .= "|%|"; } $responseStr .= escapeForJson($c_pr_parameters['item_id']).'/!/'.escapeForJson($c_pr_parameters['name_in_db']).'/!/'.escapeForJson($c_pr_parameters['category']).'/!/'.escapeForJson($c_pr_parameters['car_brand']).'/!/'.escapeForJson($c_pr_parameters['car_type']).'/!/'.escapeForJson($c_pr_parameters['car_year']).'/!/'.escapeForJson($c_pr_parameters['car_doors']); } } echo '{"result": "ok", "data": "'.$responseStr.'", "maxpage": "'.$maxpage.'", "cpage": "'.$cpage.'"}'; } else if (htmlspecialchars($_POST["func"]) == "filter") { if (!isset($_COOKIE['maxperpage'])) { setcookie("maxperpage", "25", time() + (86400 * 90), "/"); $maxperpage = "25"; } else { $maxperpage = $_COOKIE['maxperpage']; } setcookie("maxperpage", strval($maxperpage), time() + (86400 * 90), "/"); $perpageselect = " "; $perpageselect = str_replace("value='".$maxperpage."'", "value='".$maxperpage."' selected", $perpageselect); $category = ''; $query = "SELECT DISTINCT category FROM pr_parameters ORDER BY category ASC"; if ($result = $conn->query($query)) { while ($ccat = $result->fetch_assoc()) { if ($ccat['category'] != null && $ccat['category'] != "") { $category .= ""; } } } $car_brand = ''; $query = "SELECT DISTINCT car_brand FROM pr_parameters ORDER BY car_brand ASC"; if ($result = $conn->query($query)) { while ($ccar_brand = $result->fetch_assoc()) { if ($ccar_brand['car_brand'] != null && $ccar_brand['car_brand'] != "") { $car_brand .= ""; } } } $car_type = ''; $query = "SELECT DISTINCT car_type FROM pr_parameters ORDER BY car_type ASC"; if ($result = $conn->query($query)) { while ($ccar_type = $result->fetch_assoc()) { if ($ccar_type['car_type'] != null && $ccar_type['car_type'] != "") { $car_type .= ""; } } } $car_doors = ''; $query = "SELECT DISTINCT car_doors FROM pr_parameters ORDER BY car_doors ASC"; if ($result = $conn->query($query)) { while ($ccar_doors = $result->fetch_assoc()) { if ($ccar_doors['car_doors'] != null && $ccar_doors['car_doors'] != "") { $car_doors .= ""; } } } $json = json_encode(array( 'category' => $category, 'car_brand' => $car_brand, 'car_type' => $car_type, 'car_doors' => $car_doors, 'perpage' => $perpageselect, 'result' => 'ok' )); echo $json; } else if (htmlspecialchars($_POST["func"]) == "openproduct") { $item_id = htmlspecialchars(str_replace(' ', '+', $_POST['item_id'])); $json = ""; $all_product_information = array(); $data = json_decode(file_get_contents($currentUrl."/managers/prdb.json"), true); if ($data) { $Tables = []; foreach ($data["DBList"] as $table) { if (UserHasPerm($table["ID"]."_read") || UserHasPerm($table["ID"]."_edit") || UserHasPerm("edit_item_introduction_basic_data")) { $sql = mysqli_query($conn,"SELECT item_id FROM ".$table["ID"]." WHERE item_id = '$item_id'"); if (mysqli_fetch_array($sql)) { $query = "SELECT * FROM ".$table["ID"]." WHERE item_id = '$item_id'"; if ($result = $conn->query($query)) { while ($dbdata = $result->fetch_assoc()) { foreach ($data["Parameters"] as $param) { if (strpos($param["ID"], $table['ID'] . "_") === 0) { $newID = substr($param["ID"], strlen($table['ID']) + 1); if (!($dbdata["data_status"] != "0" && !UserHasPerm($table["ID"]."_read"))) { $all_product_information = array_merge($all_product_information, [$param["ID"] => $param["NAME"]."||".$dbdata[$newID]]); } } } $uploader_uid = $dbdata["uploader_uid"]; $sql = mysqli_query($conn,"SELECT full_name FROM users WHERE uid = '$uploader_uid'"); $userUploaderName = $coderclass->decode(mysqli_fetch_array($sql)[0], "TIT4"); $all_product_information = array_merge($all_product_information, [$table['ID'].'_uploader_name' => $userUploaderName]); $all_product_information = array_merge($all_product_information, [$table['ID'] => $table["NAME"]]); $all_product_information = array_merge($all_product_information, [$table['ID'].'_registration_date' => date("Y-m-d H:i:s", $dbdata["registration_date"])]); $all_product_information = array_merge($all_product_information, [$table['ID'].'_data_status' => $dbdata["data_status"]]); $EditingPerm = false; if ($dbdata["data_status"] == "0" && UserHasPerm("edit_item_introduction_basic_data")) { $EditingPerm = true; } else if (UserHasPerm($table["ID"]."_edit")) { $EditingPerm = true; } $CanSee = true; if ($dbdata["data_status"] != "0" && !UserHasPerm($table["ID"]."_read")) { $CanSee = false; } $all_product_information = array_merge($all_product_information, [$table['ID'].'_can_see' => $CanSee]); $all_product_information = array_merge($all_product_information, [$table['ID'].'_can_edit' => $EditingPerm]); } } } else if (UserHasPerm($table["ID"]."_edit") || UserHasPerm("edit_item_introduction_basic_data")) { $all_product_information = array_merge($all_product_information, [$table['ID'] => $table["NAME"]]); $all_product_information = array_merge($all_product_information, [$table['ID'].'_can_edit' => true]); } } else { $all_product_information = array_merge($all_product_information, [$table['ID'].'_can_see' => false]); } } $item_query = "SELECT average_production, average_scrap, produced_quantity, total_consumption, went_into_production, year FROM statistics_annual WHERE item_id = '" . $item_id . "' ORDER BY year DESC"; $result = mysqli_query($conn, $item_query); $statistics_annual = []; if ($result) { while ($row = mysqli_fetch_assoc($result)) { $statistics_annual[] = $row; } } $all_product_information = array_merge( $all_product_information, ["result" => "ok", "item_id" => $item_id, "statistics_annual" => $statistics_annual] ); $json = json_encode($all_product_information); } else { $json = json_encode(["result" => "DB Table loading error!"]); } echo $json; } else if (htmlspecialchars($_POST["func"]) == "addtable") { $item_id = htmlspecialchars(str_replace(' ', '+', $_POST['item_id'])); $table_id = htmlspecialchars($_POST["table_id"]); $LocalData = json_decode(file_get_contents($currentUrl."/managers/prdb.json"), true); $json = ""; if ($LocalData && (UserHasPerm("edit_item_introduction_basic_data") || UserHasPerm($table_id."_edit"))) { $isDB = false; foreach ($LocalData["DBList"] as $item) { if ($item["ID"] === $table_id) { $isDB = true; break; } } if ($isDB) { $sql = mysqli_query($conn,"SELECT item_id FROM ".$table_id." WHERE item_id = '$item_id'"); $test = mysqli_fetch_array($sql); $ctimestamp = time(); if (!$test) { $sql = mysqli_query($conn,"SELECT data_status FROM pr_parameters WHERE item_id = '$item_id'"); $DataStatus = mysqli_fetch_array($sql)[0]; $sql = mysqli_query($conn,"INSERT INTO ".$table_id." (item_id, uploader_uid, registration_date, data_status) VALUES ('".$item_id."', ".$userID.", ".$ctimestamp.", ".$DataStatus.")"); $json = json_encode(["result" => "ok"]); } else { $json = json_encode(["result" => "Ez a tábla már létezik!"]); } } else { $json = json_encode(["result" => "Nem létezik ilyen nevű táblázat!"]); } } else { $json = json_encode(["result" => "Jogosultság megtagadva!"]); } echo $json; } else if (htmlspecialchars($_POST["func"]) == "SaveNewItemIDName") { $old_item_id = htmlspecialchars(str_replace(' ', '+', $_POST['item_id'])); $new_item_id = htmlspecialchars(str_replace(' ', '+', $_POST['new_item_id'])); if (UserHasPerm("god_profile")) { $sql = mysqli_query($conn,"SELECT item_id FROM pr_parameters WHERE item_id = '$old_item_id'"); $check_item_id = mysqli_fetch_array($sql)[0]; $sql = mysqli_query($conn,"SELECT item_id FROM pr_parameters WHERE item_id = '$new_item_id'"); $check_new_item_id = mysqli_fetch_array($sql)[0]; if ($check_item_id != null && $check_new_item_id == null) { $sql = "SELECT TABLE_NAME FROM INFORMATION_SCHEMA.COLUMNS WHERE COLUMN_NAME = 'item_id';"; $result = $conn->query($sql); if ($result) { while ($row = $result->fetch_assoc()) { $table = $row['TABLE_NAME']; $update_sql = mysqli_query($conn,"UPDATE $table SET item_id = '$new_item_id' WHERE item_id = '$old_item_id'"); } $json = json_encode(["result" => "ok", "item_id" => $new_item_id]); } else { $json = json_encode(["result" => "Hiba a táblák lekérdezésekor: " . $conn->error]); } } else if ($check_item_id == null) { $json = json_encode(["result" => "Nem létező cikkszámot szeretne módosítani!"]); } else { $json = json_encode(["result" => "Ilyen azonosítóval létezik már cikkszám!"]); } } else { $json = json_encode(["result" => "Jogosultság megtagadva!"]); } echo $json; } else if (htmlspecialchars($_POST["func"]) == "GenerateExport") { $json = ""; $all_product_information = array(); $data = json_decode(file_get_contents($currentUrl."/managers/prdb.json"), true); if ($data) { $query = "SELECT item_id, data_status, price_category FROM pr_parameters"; if ($result = $conn->query($query)) { while ($c_export = $result->fetch_assoc()) { $c_item_id = $c_export['item_id']; $all_product_information[$c_item_id][] = [ "name" => 'Cikkszám', "value" => $c_item_id ]; foreach ($data["DBList"] as $table) { $c_table_id = $table["ID"]; if (UserHasPerm($c_table_id."_read") || UserHasPerm($c_table_id."_edit")) { $sql = mysqli_query($conn,"SELECT * FROM $c_table_id WHERE item_id = '$c_item_id'"); $c_result = mysqli_fetch_array($sql); foreach ($data["Parameters"] as $param) { if (strpos($param["ID"], $table['ID'] . "_") === 0) { $newID = substr($param["ID"], strlen($table['ID']) + 1); if ($c_result != null) { $all_product_information[$c_item_id][] = [ "name" => $param["NAME"], "value" => $c_result[$newID] ]; } else { $all_product_information[$c_item_id][] = [ "name" => $param["NAME"], "value" => '' ]; } } } } } $statusText = match (intval($c_export["data_status"])) { 1 => 'Értékesíthető', 0 => 'Bevezetés alatt', -1 => 'Kifutó', -2 => 'Megszűnt', default => 'Ismeretlen', }; $all_product_information[$c_item_id][] = [ "name" => 'Termék státusza', "value" => $statusText ]; $category_name = $c_export["price_category"]; $query_price = "SELECT type_name, currency, price FROM customer_types WHERE is_active = 1 and category_name = '$category_name'"; if ($result_price = $conn->query($query_price)) { while ($c_price = $result_price->fetch_assoc()) { $all_product_information[$c_item_id][] = [ "name" => $c_price['type_name'] . ' ár', "value" => $c_price['price'] . ' ' . $c_price['currency'] ]; } } } } $json = json_encode(["result" => "ok", "data" => $all_product_information]); } else { $json = json_encode(["result" => "DB Table loading error!"]); } echo $json; } exit(); } else if (isset($_GET['saving']) && $_GET['saving'] == 1) { header("Content-Type: application/json"); $jsonData = file_get_contents("php://input"); $data = json_decode($jsonData, true); $LocalData = json_decode(file_get_contents($currentUrl."/managers/prdb.json"), true); if ($data) { $tables = []; foreach ($data as $key => $value) { if (strpos($key, "_can_edit") !== false && $value === "true") { $tableName = str_replace("_can_edit", "", $key); $sql = mysqli_query($conn,"SELECT data_status FROM ".$tableName." WHERE item_id = '".$data['item_id']."'"); $tableDataStatus = mysqli_fetch_array($sql)[0]; $EditingPerm = false; if ($tableDataStatus == "0" && UserHasPerm("edit_item_introduction_basic_data")) { $EditingPerm = true; } else if (UserHasPerm($tableName.'_edit')) { $EditingPerm = true; } if ($EditingPerm) { $tables[] = $tableName; } } } $response = []; foreach ($tables as $table) { $updateFields = []; $updateValues = []; foreach ($data as $key => $value) { if (strpos($key, $table . "_") === 0 && $key !== $table . "_can_edit") { $columnName = str_replace($table . "_", "", $key); if ($table == "pr_warehouse_parameters" && $columnName == "size" && $data[$table."_".$columnName] != "") { $boxsizeoptions = array_column($LocalData['BoxSizes'], 'Name'); if (!in_array($data[$table."_".$columnName], $boxsizeoptions, true)) { echo json_encode(["status" => "error", "message" => "Nem megfelelő doboz méretet adott meg a Raktározási paramétereknél!"]); die(); } } $updateFields[] = "$columnName = '".htmlspecialchars($data[$table."_".$columnName])."'"; $updateValues[] = $value; } } if (!empty($updateFields)) { $updateQuery = "UPDATE $table SET " . implode(", ", $updateFields) . " WHERE item_id = '".$data['item_id']."'"; $sql = mysqli_query($conn, $updateQuery); } } echo json_encode(["status" => "done", "updates" => $response]); } else { echo json_encode(["status" => "error", "message" => "Hibás adat"]); } exit(); } ?> Kezelőfelület

Title

Termékkatalógus

external-xlsx-file-file-extension-fauzidea-flat-fauzidea

Cikkszám:

Terméknév:

Termékkategória:

Autó:

Típus:

Évjárat:

Ajtók:

Adat státusza:

'; } else { echo ''; } ?>

Oldalanként:

:



Cikkszám Terméknév Termékkategória Autó Típus Évjárat Ajtók Adatlap

<    0 / 0    >