query($query)) { while ($introduction = $result->fetch_assoc()) { $user_can_edit = 2; $status_text = ""; if (UserHasPerm('read_item_introduction')) {$user_can_edit = 3;} if ($introduction["status"] == "basic_data") {if (UserHasPerm('edit_item_introduction_basic_data')) {$user_can_edit = 1;}$status_text = "Alap adatok feltöltése";} if ($introduction["status"] == "tools_send") {if (UserHasPerm('edit_item_introduction_tools_send')) {$user_can_edit = 1;}$status_text = "Szerszámtervek vágásra továbbküldve";} if ($introduction["status"] == "testing") {if (UserHasPerm('edit_item_introduction_testing')) {$user_can_edit = 1;}$status_text = "Termékpróba szakasz";} if ($introduction["status"] == "deficit") {if (UserHasPerm('edit_item_introduction_basic_data')) {$user_can_edit = 1;}$status_text = "Adatpótlási szakasz";} if ($introduction["status"] == "last_statement") {if (UserHasPerm('edit_item_introduction_basic_data')) {$user_can_edit = 1;}$status_text = "Végső nyilatkozatok beküldése";} if ($introduction["status"] == "final") {if (UserHasPerm('edit_item_introduction_final')) {$user_can_edit = 1;}$status_text = "Végső ellenőrzés";} $IntroductionItems[] = [ "item_id" => $introduction["item_id"], "status" => $status_text, "user_can_edit" => $user_can_edit ]; } } usort($IntroductionItems, function ($a, $b) {return strcoll($a["user_can_edit"], $b["user_can_edit"]);}); $responseStr = ''; for ($i=0; $i < count($IntroductionItems); $i++) { if ($responseStr != "") { $responseStr = $responseStr."|%|"; } $responseStr = $responseStr.$IntroductionItems[$i]['item_id'].'||'.$IntroductionItems[$i]['status'].'||'.$IntroductionItems[$i]['user_can_edit']; } echo '{"status": "ok", "data": "'.$responseStr.'"}'; } else if (htmlspecialchars($_POST["func"]) == "SaveNewIntroduction") { $item_id = htmlspecialchars(str_replace(' ', '+', $_POST['item_id'])); $json = ""; $sql = mysqli_query($conn,"SELECT name_in_db FROM pr_parameters WHERE item_id = '$item_id'"); $pr_parameters = mysqli_fetch_array($sql); $sql = mysqli_query($conn,"SELECT status FROM item_introduction WHERE item_id = '$item_id'"); $item_introduction = mysqli_fetch_array($sql); if ($item_id == "") { $json = json_encode(["status" => "error", "message" => "Kötelező egy cikkszámot megadni!"]); } else if ($pr_parameters) { $json = json_encode(["status" => "error", "message" => "A megadott cikkszámmal, már létezik Termék!"]); } else if ($item_introduction) { $json = json_encode(["status" => "error", "message" => "A megadott cikkszámmal, már megkezdődött a bevezetési folyamat!"]); } else if(!UserHasPerm('edit_item_introduction_basic_data')) { $json = json_encode(["status" => "error", "message" => "Jogosultság megtagadva! Önnek nincsen joga termék bevezetést elkezdeni!"]); } else { $sql = mysqli_query($conn,"INSERT INTO item_introduction(item_id, status) VALUES ('$item_id', 'basic_data')"); $json = json_encode(["status" => "ok"]); } echo $json; } else if (htmlspecialchars($_POST["func"]) == "OpenIntroduction") { $item_id = htmlspecialchars(str_replace(' ', '+', $_POST['item_id'])); $json = ""; $sql = mysqli_query($conn,"SELECT status FROM item_introduction WHERE item_id = '$item_id'"); $item_introduction = mysqli_fetch_array($sql); if ($item_introduction) { $json = json_encode(["status" => "ok", "current_stage" => $item_introduction["status"]]); } else { $json = json_encode(["status" => "error", "message" => "A megadott cikkszámmal nem létezik bevezetési folyamat!"]); } echo $json; } else if (htmlspecialchars($_POST["func"]) == "StartToolsSend") { $item_id = htmlspecialchars(str_replace(' ', '+', $_POST['item_id'])); $json = ""; if (UserHasPerm('edit_item_introduction_basic_data')) { $json = json_encode(["status" => "ok"]); $sql = mysqli_query($conn,"UPDATE item_introduction SET status = 'tools_send' WHERE item_id = '$item_id'"); } else { $json = json_encode(["status" => "error", "message" => "Jogosultság megtagadva! Önnek nincsen joga alap adatokat menteni!"]); } echo $json; } else if (htmlspecialchars($_POST["func"]) == "OpenBasicData") { $item_id = htmlspecialchars(str_replace(' ', '+', $_POST['item_id'])); $json = ""; $IsUserCanEdit = UserHasPerm('edit_item_introduction_basic_data'); $all_product_information = array(); $data = json_decode(file_get_contents($currentUrl."/managers/prdb.json"), true); if ($data) { foreach ($data["DBList"] as $table) { $sql = mysqli_query($conn,"SELECT item_id FROM ".$table["ID"]." WHERE item_id = '$item_id'"); $test = mysqli_fetch_array($sql); if ($test) { //Ha létezik már adat erről a cikkszámról $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); $all_product_information = array_merge($all_product_information, [$param["ID"] => $param["NAME"]."||".$dbdata[$newID]]); if ($param["DATALIST"]) { $query = "SELECT DISTINCT $newID FROM ".$table["ID"]." ORDER BY $newID ASC"; $GeneratedDatalist = ""; if ($result = $conn->query($query)) { while ($datalist = $result->fetch_assoc()) { $GeneratedDatalist .= ''; } } $all_product_information = array_merge($all_product_information, [$param["ID"]."_datalist" => $GeneratedDatalist]); } else { $all_product_information = array_merge($all_product_information, [$param["ID"]."_datalist" => ""]); } } } $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'] => $table["NAME"]]); $all_product_information = array_merge($all_product_information, [$table['ID'].'_can_see' => true]); $all_product_information = array_merge($all_product_information, [$table['ID'].'_can_edit' => $IsUserCanEdit]); } } } else { //Ha még nem létezik adat ebben a táblában a cikkszámról foreach ($data["Parameters"] as $param) { if (strpos($param["ID"], $table['ID'] . "_") === 0) { $newID = substr($param["ID"], strlen($table['ID']) + 1); $all_product_information = array_merge($all_product_information, [$param["ID"] => $param["NAME"]."||+"]); $all_product_information = array_merge($all_product_information, [$table['ID'] => $table["NAME"]]); $all_product_information = array_merge($all_product_information, [$table['ID'].'_can_see' => true]); $all_product_information = array_merge($all_product_information, [$table['ID'].'_can_edit' => $IsUserCanEdit]); if ($param["DATALIST"]) { $query = "SELECT DISTINCT $newID FROM ".$table["ID"]." ORDER BY $newID ASC"; $GeneratedDatalist = ""; if ($result = $conn->query($query)) { while ($datalist = $result->fetch_assoc()) { $GeneratedDatalist .= ''; } } $all_product_information = array_merge($all_product_information, [$param["ID"]."_datalist" => $GeneratedDatalist]); } else { $all_product_information = array_merge($all_product_information, [$param["ID"]."_datalist" => ""]); } } } } } $all_product_information = array_merge($all_product_information, ["status" => "ok", 'item_id' => $item_id]); $json = json_encode($all_product_information); } echo $json; } else if (htmlspecialchars($_POST["func"]) == "OpenToolsSend") { $item_id = htmlspecialchars(str_replace(' ', '+', $_POST['item_id'])); $json = ""; $sql = mysqli_query($conn,"SELECT is_tool_ok, is_tool_created, is_tool_can_be_tested FROM item_introduction WHERE item_id = '$item_id'"); $item_introduction = mysqli_fetch_array($sql); if ($item_introduction) { $is_tool_ok = ''; $is_tool_created = ''; $is_tool_can_be_tested = ''; if ($item_introduction["is_tool_ok"] != null && $item_introduction["is_tool_ok"] != "") { $is_tool_ok_uid = explode("|", $item_introduction["is_tool_ok"])[0]; $sql = mysqli_query($conn,"SELECT full_name FROM users WHERE uid = '$is_tool_ok_uid'"); $is_tool_ok_name = $coderclass->decode(mysqli_fetch_array($sql)[0], "TIT4"); $is_tool_ok_time = explode("|", $item_introduction["is_tool_ok"])[1]; $is_tool_ok = $is_tool_ok_name." - ".date("Y-m-d H:i:s", $is_tool_ok_time); } if ($item_introduction["is_tool_created"] != null && $item_introduction["is_tool_created"] != "") { $is_tool_created_uid = explode("|", $item_introduction["is_tool_created"])[0]; $sql = mysqli_query($conn,"SELECT full_name FROM users WHERE uid = '$is_tool_created_uid'"); $is_tool_created_name = $coderclass->decode(mysqli_fetch_array($sql)[0], "TIT4"); $is_tool_created_time = explode("|", $item_introduction["is_tool_created"])[1]; $is_tool_created = $is_tool_created_name." - ".date("Y-m-d H:i:s", $is_tool_created_time); } if ($item_introduction["is_tool_can_be_tested"] != null && $item_introduction["is_tool_can_be_tested"] != "") { $is_tool_can_be_tested_uid = explode("|", $item_introduction["is_tool_can_be_tested"])[0]; $sql = mysqli_query($conn,"SELECT full_name FROM users WHERE uid = '$is_tool_can_be_tested_uid'"); $is_tool_can_be_tested_name = $coderclass->decode(mysqli_fetch_array($sql)[0], "TIT4"); $is_tool_can_be_tested_time = explode("|", $item_introduction["is_tool_can_be_tested"])[1]; $is_tool_can_be_tested = $is_tool_can_be_tested_name." - ".date("Y-m-d H:i:s", $is_tool_can_be_tested_time); } $json = json_encode([ "status" => "ok", "is_tool_ok" => $is_tool_ok, "is_tool_created" => $is_tool_created, "is_tool_can_be_tested" => $is_tool_can_be_tested, "user_can_edit" => UserHasPerm("edit_item_introduction_tools_send") ]); } else { $json = json_encode(["status" => "error", "message" => "A megadott cikkszámmal nem létezik bevezetési folyamat!"]); } echo $json; } else if (htmlspecialchars($_POST["func"]) == "OpenTesting") { $item_id = htmlspecialchars(str_replace(' ', '+', $_POST['item_id'])); $json = ""; $sql = mysqli_query($conn,"SELECT is_tested_in_car, is_production_ready FROM item_introduction WHERE item_id = '$item_id'"); $item_introduction = mysqli_fetch_array($sql); if ($item_introduction) { $is_tested_in_car = ''; $is_production_ready = ''; if ($item_introduction["is_tested_in_car"] != null && $item_introduction["is_tested_in_car"] != "") { $is_tested_in_car_uid = explode("|", $item_introduction["is_tested_in_car"])[0]; $sql = mysqli_query($conn,"SELECT full_name FROM users WHERE uid = '$is_tested_in_car_uid'"); $is_tested_in_car_name = $coderclass->decode(mysqli_fetch_array($sql)[0], "TIT4"); $is_tested_in_car_time = explode("|", $item_introduction["is_tested_in_car"])[1]; $is_tested_in_car = $is_tested_in_car_name." - ".date("Y-m-d H:i:s", $is_tested_in_car_time); } if ($item_introduction["is_production_ready"] != null && $item_introduction["is_production_ready"] != "") { $is_production_ready_uid = explode("|", $item_introduction["is_production_ready"])[0]; $sql = mysqli_query($conn,"SELECT full_name FROM users WHERE uid = '$is_production_ready_uid'"); $is_production_ready_name = $coderclass->decode(mysqli_fetch_array($sql)[0], "TIT4"); $is_production_ready_time = explode("|", $item_introduction["is_production_ready"])[1]; if (count(explode("|", $item_introduction["is_production_ready"])) == 3) { $is_production_ready = "".explode("|", $item_introduction["is_production_ready"])[2]." - ".$is_production_ready_name." - ".date("Y-m-d H:i:s", $is_production_ready_time); } else { $is_production_ready = $is_production_ready_name." - ".date("Y-m-d H:i:s", $is_production_ready_time); } } $json = json_encode([ "status" => "ok", "is_tested_in_car" => $is_tested_in_car, "is_production_ready" => $is_production_ready, "user_can_edit" => UserHasPerm("edit_item_introduction_testing") ]); } else { $json = json_encode(["status" => "error", "message" => "A megadott cikkszámmal nem létezik bevezetési folyamat!"]); } echo $json; } else if (htmlspecialchars($_POST["func"]) == "OpenLastStatement") { $item_id = htmlspecialchars(str_replace(' ', '+', $_POST['item_id'])); $json = ""; $sql = mysqli_query($conn,"SELECT is_kulcssoft_ready, is_on_web, is_data_valid, is_export_ready FROM item_introduction WHERE item_id = '$item_id'"); $item_introduction = mysqli_fetch_array($sql); if ($item_introduction) { $is_kulcssoft_ready = ''; $is_on_web = ''; $is_data_valid = ''; $is_export_ready = ''; if ($item_introduction["is_kulcssoft_ready"] != null && $item_introduction["is_kulcssoft_ready"] != "") { $is_kulcssoft_ready_uid = explode("|", $item_introduction["is_kulcssoft_ready"])[0]; $sql = mysqli_query($conn,"SELECT full_name FROM users WHERE uid = '$is_kulcssoft_ready_uid'"); $is_kulcssoft_ready_name = $coderclass->decode(mysqli_fetch_array($sql)[0], "TIT4"); $is_kulcssoft_ready_time = explode("|", $item_introduction["is_kulcssoft_ready"])[1]; $is_kulcssoft_ready = $is_kulcssoft_ready_name." - ".date("Y-m-d H:i:s", $is_kulcssoft_ready_time); } if ($item_introduction["is_on_web"] != null && $item_introduction["is_on_web"] != "") { $is_on_web_uid = explode("|", $item_introduction["is_on_web"])[0]; $sql = mysqli_query($conn,"SELECT full_name FROM users WHERE uid = '$is_on_web_uid'"); $is_on_web_name = $coderclass->decode(mysqli_fetch_array($sql)[0], "TIT4"); $is_on_web_time = explode("|", $item_introduction["is_on_web"])[1]; $is_on_web = $is_on_web_name." - ".date("Y-m-d H:i:s", $is_on_web_time); } if ($item_introduction["is_data_valid"] != null && $item_introduction["is_data_valid"] != "") { $is_data_valid_uid = explode("|", $item_introduction["is_data_valid"])[0]; $sql = mysqli_query($conn,"SELECT full_name FROM users WHERE uid = '$is_data_valid_uid'"); $is_data_valid_name = $coderclass->decode(mysqli_fetch_array($sql)[0], "TIT4"); $is_data_valid_time = explode("|", $item_introduction["is_data_valid"])[1]; $is_data_valid = $is_data_valid_name." - ".date("Y-m-d H:i:s", $is_data_valid_time); } if ($item_introduction["is_export_ready"] != null && $item_introduction["is_export_ready"] != "") { $is_export_ready_uid = explode("|", $item_introduction["is_export_ready"])[0]; $sql = mysqli_query($conn,"SELECT full_name FROM users WHERE uid = '$is_export_ready_uid'"); $is_export_ready_name = $coderclass->decode(mysqli_fetch_array($sql)[0], "TIT4"); $is_export_ready_time = explode("|", $item_introduction["is_export_ready"])[1]; $is_export_ready = $is_export_ready_name." - ".date("Y-m-d H:i:s", $is_export_ready_time); } $json = json_encode([ "status" => "ok", "is_kulcssoft_ready" => $is_kulcssoft_ready, "is_on_web" => $is_on_web, "is_data_valid" => $is_data_valid, "is_export_ready" => $is_export_ready, "user_can_edit" => UserHasPerm("edit_item_introduction_basic_data") ]); } else { $json = json_encode(["status" => "error", "message" => "A megadott cikkszámmal nem létezik bevezetési folyamat!"]); } echo $json; } else if (htmlspecialchars($_POST["func"]) == "OpenFinal") { $item_id = htmlspecialchars(str_replace(' ', '+', $_POST['item_id'])); $all_information = array(); $Parameters = ["is_tool_ok", "is_tool_created", "is_tool_can_be_tested", "is_tested_in_car", "is_production_ready", "is_kulcssoft_ready", "is_on_web", "is_data_valid", "is_export_ready"]; for ($i=0; $i < count($Parameters); $i++) { $sql = mysqli_query($conn,"SELECT ".$Parameters[$i]." FROM item_introduction WHERE item_id = '$item_id'"); $item_introduction = mysqli_fetch_array($sql); $this_uid = explode("|", $item_introduction[0])[0]; $sql = mysqli_query($conn,"SELECT full_name FROM users WHERE uid = '$this_uid'"); $this_name = $coderclass->decode(mysqli_fetch_array($sql)[0], "TIT4"); $this_time = explode("|", $item_introduction[0])[1]; $temp = $this_name." - ".date("Y-m-d H:i:s", $this_time); $all_information = array_merge($all_information, [$Parameters[$i] => $temp]); } $all_information = array_merge($all_information, ['status' => 'ok']); $all_information = array_merge($all_information, ['user_can_edit' => UserHasPerm("edit_item_introduction_final")]); echo json_encode($all_information); } else if (htmlspecialchars($_POST["func"]) == "OpenComplete") { $item_id = htmlspecialchars(str_replace(' ', '+', $_POST['item_id'])); if (UserHasPerm('read_item_introduction') || UserHasPerm('edit_item_introduction_final')) { $sql = mysqli_query($conn,"SELECT finalized_by, finalized_in FROM item_introduction WHERE item_id = '$item_id'"); $item_introduction = mysqli_fetch_array($sql); $this_uid = $item_introduction["finalized_by"]; $sql = mysqli_query($conn,"SELECT full_name FROM users WHERE uid = '$this_uid'"); $this_name = $coderclass->decode(mysqli_fetch_array($sql)[0], "TIT4"); $json = json_encode([ "status" => "ok", "finalized_by" => $this_name, "finalized_in" => date("Y-m-d H:i:s", $item_introduction["finalized_in"]) ]); } else { $json = json_encode(["status" => "error", "message" => "Jogosultság megtagadva! Önnek nincsen joga megtekinteni a lezárt Termék bevezetéseket!"]); } echo $json; } else if (htmlspecialchars($_POST["func"]) == "StatementEditor") { $item_id = htmlspecialchars(str_replace(' ', '+', $_POST['item_id'])); $statement_id = htmlspecialchars($_POST["statement_id"]); $edit_to = htmlspecialchars($_POST["edit_to"]); $input = htmlspecialchars($_POST["input"]); $json = ""; $userMustHaveThisPerm = "god_profile"; if ($statement_id == "is_tool_ok" || $statement_id == "is_tool_created" || $statement_id == "is_tool_can_be_tested") { $userMustHaveThisPerm = "edit_item_introduction_tools_send"; } else if ($statement_id == "is_tested_in_car" || $statement_id == "is_production_ready") { $userMustHaveThisPerm = "edit_item_introduction_testing"; } else if ($statement_id == "is_kulcssoft_ready" || $statement_id == "is_on_web" || $statement_id == "is_data_valid" || $statement_id == "is_export_ready") { $userMustHaveThisPerm = "edit_item_introduction_basic_data"; } if (UserHasPerm($userMustHaveThisPerm)) { $text = ""; if ($edit_to == "true") { $toupdate = $userID."|".(time()); if ($input != "igen") { $toupdate .= "|".$input; $sql = mysqli_query($conn,"UPDATE item_introduction SET ".$statement_id." = '".$toupdate."' WHERE item_id = '$item_id'"); $text = "".$input." - ".$userName." - ".date("Y-m-d H:i:s", (time())); } else { $sql = mysqli_query($conn,"UPDATE item_introduction SET ".$statement_id." = '".$toupdate."' WHERE item_id = '$item_id'"); $text = $userName." - ".date("Y-m-d H:i:s", (time())); } } else { $sql = mysqli_query($conn,"UPDATE item_introduction SET ".$statement_id." = null WHERE item_id = '$item_id'"); } $json = json_encode(["result" => "ok", "text" => $text]); } else { $json = json_encode(["result" => "Jogosultság megtagadva! Önnek nincsen joga ezt a nyilatkozat benyújtani!"]); } echo $json; } else if (htmlspecialchars($_POST["func"]) == "StartTesting") { $item_id = htmlspecialchars(str_replace(' ', '+', $_POST['item_id'])); $json = ""; $sql = mysqli_query($conn,"SELECT is_tool_ok, is_tool_created, is_tool_can_be_tested FROM item_introduction WHERE item_id = '$item_id'"); $item_introduction = mysqli_fetch_array($sql); if ($item_introduction["is_tool_ok"] == null || $item_introduction["is_tool_ok"] == "" || $item_introduction["is_tool_created"] == null || $item_introduction["is_tool_created"] == "" ||$item_introduction["is_tool_can_be_tested"] == null || $item_introduction["is_tool_can_be_tested"] == "") { $json = json_encode(["status" => "error", "message" => "Minden nyilatkozatot be kell nyújtani!"]); } else if (UserHasPerm('edit_item_introduction_tools_send')) { $json = json_encode(["status" => "ok"]); $sql = mysqli_query($conn,"UPDATE item_introduction SET status = 'testing' WHERE item_id = '$item_id'"); } else { $json = json_encode(["status" => "error", "message" => "Jogosultság megtagadva! Önnek nincsen joga alap adatokat menteni!"]); } echo $json; } else if (htmlspecialchars($_POST["func"]) == "StartDeficit") { $item_id = htmlspecialchars(str_replace(' ', '+', $_POST['item_id'])); $json = ""; $sql = mysqli_query($conn,"SELECT is_tested_in_car, is_production_ready FROM item_introduction WHERE item_id = '$item_id'"); $item_introduction = mysqli_fetch_array($sql); if ($item_introduction["is_tested_in_car"] == null || $item_introduction["is_tested_in_car"] == "" || $item_introduction["is_production_ready"] == null || $item_introduction["is_production_ready"] == "") { $json = json_encode(["status" => "error", "message" => "Minden nyilatkozatot be kell nyújtani!"]); } else if (count(explode("|", $item_introduction["is_production_ready"])) != 2) { $json = json_encode(["status" => "error", "message" => "A Termék nem sorozatgyártható! Csak abban az esetben lehet folytatni, ha a termék sorozatgyártásba felvehető!"]); } else if (UserHasPerm('edit_item_introduction_testing')) { $json = json_encode(["status" => "ok"]); $sql = mysqli_query($conn,"UPDATE item_introduction SET status = 'deficit' WHERE item_id = '$item_id'"); } else { $json = json_encode(["status" => "error", "message" => "Jogosultság megtagadva! Önnek nincsen joga alap adatokat menteni!"]); } echo $json; } else if (htmlspecialchars($_POST["func"]) == "StartLastStatement") { $item_id = htmlspecialchars(str_replace(' ', '+', $_POST['item_id'])); $json = ""; if (UserHasPerm('edit_item_introduction_basic_data')) { $json = json_encode(["status" => "ok"]); $sql = mysqli_query($conn,"UPDATE item_introduction SET status = 'last_statement' WHERE item_id = '$item_id'"); } else { $json = json_encode(["status" => "error", "message" => "Jogosultság megtagadva! Önnek nincsen joga alap adatokat menteni!"]); } echo $json; } else if (htmlspecialchars($_POST["func"]) == "StartFinal") { $item_id = htmlspecialchars(str_replace(' ', '+', $_POST['item_id'])); $json = ""; $sql = mysqli_query($conn,"SELECT is_kulcssoft_ready, is_on_web, is_data_valid, is_export_ready FROM item_introduction WHERE item_id = '$item_id'"); $item_introduction = mysqli_fetch_array($sql); if ($item_introduction["is_kulcssoft_ready"] == null || $item_introduction["is_kulcssoft_ready"] == "" || $item_introduction["is_on_web"] == null || $item_introduction["is_on_web"] == "" || $item_introduction["is_data_valid"] == null || $item_introduction["is_data_valid"] == "" || $item_introduction["is_export_ready"] == null || $item_introduction["is_export_ready"] == "") { $json = json_encode(["status" => "error", "message" => "Minden nyilatkozatot be kell nyújtani!"]); } else if (UserHasPerm('edit_item_introduction_basic_data')) { $json = json_encode(["status" => "ok"]); $sql = mysqli_query($conn,"UPDATE item_introduction SET status = 'final' WHERE item_id = '$item_id'"); } else { $json = json_encode(["status" => "error", "message" => "Jogosultság megtagadva! Önnek nincsen joga alap adatokat menteni!"]); } echo $json; } else if (htmlspecialchars($_POST["func"]) == "StartComplete") { $item_id = htmlspecialchars(str_replace(' ', '+', $_POST['item_id'])); $json = ""; if (UserHasPerm('edit_item_introduction_final')) { $json = json_encode(["status" => "ok"]); $ctime = time(); $sql = mysqli_query($conn,"UPDATE item_introduction SET status = 'complete', finalized_in = $ctime, finalized_by = $userID WHERE item_id = '$item_id'"); $_GET['type'] = 'daily'; $_GET['item_id'] = $item_id; $_GET['silent'] = true; include '../managers/statistics.php'; $data = json_decode(file_get_contents($currentUrl."/managers/prdb.json"), true); if ($data) { foreach ($data["DBList"] as $table) { $sqlcommand = 'UPDATE '.$table["ID"].' SET data_status = 1 WHERE item_id = "'.$item_id.'"'; $sql = mysqli_query($conn,$sqlcommand); } } } else { $json = json_encode(["status" => "error", "message" => "Jogosultság megtagadva! Önnek nincsen joga alap adatokat menteni!"]); } echo $json; } else if (htmlspecialchars($_POST["func"]) == "filter" && UserHasPerm("read_item_introduction")) { 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); $finalized_by = ''; $query = "SELECT DISTINCT finalized_by FROM item_introduction WHERE status = 'complete' ORDER BY finalized_by ASC"; if ($result = $conn->query($query)) { while ($ccat = $result->fetch_assoc()) { if ($ccat['finalized_by'] != null && $ccat['finalized_by'] != "") { $this_uid = $ccat['finalized_by']; $sql = mysqli_query($conn,"SELECT full_name FROM users WHERE uid = '$this_uid'"); $this_name = $coderclass->decode(mysqli_fetch_array($sql)[0], "TIT4"); $finalized_by .= ""; } } } $json = json_encode(array( 'finalized_by' => $finalized_by, 'perpage' => $perpageselect, 'result' => 'ok' )); echo $json; } else if (htmlspecialchars($_POST["func"]) == "table" && UserHasPerm("read_item_introduction")) { $maxperpage = intval(htmlspecialchars($_POST["perpage"])); $cpage = intval(htmlspecialchars($_POST["cpage"])); $orderby = htmlspecialchars($_POST["orderby"]); $start_datetime = htmlspecialchars($_POST["start_datetime"]); $end_datetime = htmlspecialchars($_POST["end_datetime"]); $finalized_by = htmlspecialchars($_POST["finalized_by"]); $item_id = htmlspecialchars(str_replace(' ', '+', $_POST['item_id'])); $addquery = ""; $isfirst = true; if ($cpage == 0) { $cpage = 1; } setcookie("maxperpage", $maxperpage, time() + (86400 * 90), "/"); if ($finalized_by != "") { $addquery = $addquery." WHERE finalized_by LIKE '%".$finalized_by."%'"; $isfirst = false; } if ($start_datetime != "") { $timestamp = strtotime($start_datetime); if ($isfirst) { $addquery = $addquery." WHERE finalized_in > '".$timestamp."'"; $isfirst = false; } else { $addquery = $addquery." and finalized_in > '".$timestamp."'"; } } if ($end_datetime != "") { $timestamp = strtotime($end_datetime); if ($isfirst) { $addquery = $addquery." WHERE finalized_in < '".$timestamp."'"; $isfirst = false; } else { $addquery = $addquery." and finalized_in < '".$timestamp."'"; } } if ($item_id != "") { if ($isfirst) { $addquery = $addquery." WHERE item_id LIKE '%".$item_id."%'"; $isfirst = false; } else { $addquery = $addquery." and item_id LIKE '%".$item_id."%'"; } } if ($isfirst) { $addquery = $addquery." WHERE status = 'complete'"; $isfirst = false; } else { $addquery = $addquery." and status = 'complete'"; } $sql = mysqli_query($conn,"SELECT COUNT(*) FROM item_introduction".$addquery); $count = mysqli_fetch_array($sql)[0]; if ($orderby != "") { $addquery = $addquery." ORDER BY ".$orderby; if ($orderby == "finalized_in") { $addquery .= " DESC"; } $isfirst = false; } $maxpage = ceil($count / $maxperpage); if (!($cpage >= 1 && $cpage <= $maxpage)) { $cpage = 1; } $limit = ($cpage - 1) * $maxperpage; $responseStr = ''; $query = "SELECT item_id, finalized_in, finalized_by FROM item_introduction".$addquery." LIMIT $limit, $maxperpage"; if ($result = $conn->query($query)) { while ($c_item_introduction = $result->fetch_assoc()) { if ($responseStr != "") { $responseStr .= "|%|"; } $this_uid = $c_item_introduction['finalized_by']; $sql = mysqli_query($conn,"SELECT full_name FROM users WHERE uid = '$this_uid'"); $this_name = $coderclass->decode(mysqli_fetch_array($sql)[0], "TIT4"); $responseStr .= $c_item_introduction['item_id'].'/!/'.date("Y. m. d.", $c_item_introduction['finalized_in']).'/!/'.$this_name; } } echo '{"result": "ok", "data": "'.$responseStr.'", "maxpage": "'.$maxpage.'", "cpage": "'.$cpage.'"}'; } exit(); } else if (isset($_GET['saving']) && $_GET['saving'] == 1) { header("Content-Type: application/json"); $jsonData = file_get_contents("php://input"); $SendedData = json_decode($jsonData, true); $LocalData = json_decode(file_get_contents($currentUrl."/managers/prdb.json"), true); $item_id = $SendedData['item_id']; $result_list = []; $parameters = []; if ($LocalData && UserHasPerm("edit_item_introduction_basic_data")) { foreach ($LocalData["DBList"] as $table) { foreach ($SendedData as $key => $value) { if (strpos($key, $table["ID"] . "_") === 0) { $param = substr($key, strlen($table["ID"]) + 1); $result_list[$table["ID"]][] = ['param' => $param, 'value' => $value]; } } } if (!empty($result_list)) { foreach ($result_list as $table_id => $parameters) { $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,"INSERT INTO ".$table_id."(item_id, uploader_uid, registration_date) VALUES ('".$item_id."', ".$userID.", ".$ctimestamp.")"); } foreach ($parameters as $param) { $param_name = $param['param']; $param_value = $param['value']; if ($table_id == "pr_warehouse_parameters" && $param_name == "size" && $param_value != "") { $boxsizeoptions = array_column($LocalData['BoxSizes'], 'Name'); if (in_array($param_value, $boxsizeoptions, true)) { $sql = mysqli_query($conn,"UPDATE ".$table_id." SET ".$param_name." = '".$param_value."' WHERE item_id = '".$item_id."'"); } else { die(json_encode(["status" => "Nem megfelelő doboz méretet adott meg!", "id" => "pr_warehouse_parameters_size"])); } } else { $sql = mysqli_query($conn,"UPDATE ".$table_id." SET ".$param_name." = '".$param_value."' WHERE item_id = '".$item_id."'"); } } } } } echo json_encode(["status" => "done"]); exit(); } ?> Kezelőfelület

Title

Termék (cikkszám) bevezetése

Új termék hozzáadása

Egy új termék bevezetésének elkezdése


'; } ?>