<?php
include "../../root.class.php";
$db = new db_safeguard();
// var_dump($_POST);
// if(isset($_POST['sorting_id'])){
$sorting_id = $_POST['sorting_id'];
$user_id = $_SESSION['user_id'];
$index = 0;

try {
    foreach ($_POST['equipment_id'] as $equipment_id) {

        $answer = $_POST['clean_' . $equipment_id][0];
        $comment = $_POST['clean_comment_' . $equipment_id][0];
        $text = $_POST['text_clean_' . $equipment_id][0];
        $db->query("sorting_equipment_check_list", "INSERT INTO `sorting_equipment_check_list`(`equipment_id`, `text`, `user_id`, `sorting_id`,`question`,`comment`) VALUES ('$equipment_id','$answer','$user_id','$sorting_id','$text','$comment')");
        $answer = $_POST['excessive_' . $equipment_id][0];
        $comment = $_POST['excessive_comment_' . $equipment_id][0];
        $text = $_POST['text_excessive_' . $equipment_id][0];
        $db->query("sorting_equipment_check_list", "INSERT INTO `sorting_equipment_check_list`(`equipment_id`, `text`, `user_id`, `sorting_id`,`question`,`comment`) VALUES ('$equipment_id','$answer','$user_id','$sorting_id','$text','$comment')");
        $text = $_POST['text_guardsk_' . $equipment_id][0];
        $comment = $_POST['guardsk_comment_' . $equipment_id][0];
        $answer = $_POST['guardsk_' . $equipment_id][0];
        $db->query("sorting_equipment_check_list", "INSERT INTO `sorting_equipment_check_list`(`equipment_id`, `text`, `user_id`, `sorting_id`,`question`,`comment`) VALUES ('$equipment_id','$answer','$user_id','$sorting_id','$text','$comment')");
        $text = $_POST['text_Moving_' . $equipment_id][0];
        $comment = $_POST['Moving_comment_' . $equipment_id][0];
        $answer = $_POST['Moving_' . $equipment_id][0];
        $db->query("sorting_equipment_check_list", "INSERT INTO `sorting_equipment_check_list`(`equipment_id`, `text`, `user_id`, `sorting_id`,`question`,`comment`) VALUES ('$equipment_id','$answer','$user_id','$sorting_id','$text','$comment')");
        $text = $_POST['text_Power_' . $equipment_id][0];
        $comment = $_POST['Power_comment_' . $equipment_id][0];
        $answer = $_POST['Power_' . $equipment_id][0];
        $db->query("sorting_equipment_check_list", "INSERT INTO `sorting_equipment_check_list`(`equipment_id`, `text`, `user_id`, `sorting_id`,`question`,`comment`) VALUES ('$equipment_id','$answer','$user_id','$sorting_id','$text','$comment')");
    }

    $index++;
    echo 1;

} catch (Exception $e) {
    echo $e->getMessage();
}
// }