<?php
$translation        = \DynCom\mysyde\common\classes\Registry::get("translation");
$formname           = "form_field_list";
$inputname          = "input_id";
$input_page_id      = (isset($_REQUEST["input_page_id"]) ? $_REQUEST["input_page_id"] : "");
$input_component_id = (isset($_REQUEST["input_component_id"]) ? $_REQUEST["input_component_id"] : "");
?>

<form id="<?= $formname ?>" name="<?= $formname ?>" method="post">
    <input name="input_id" type="hidden" value="<?= $input_id ?>">
    <input type="hidden" class="selected_linklist_row" name="input_line_id" value="" />
    <input type="hidden" name="input_page_id" value="<?php echo $input_page_id; ?>" />
    <input type="hidden" name="input_component_id" value="<?php echo $input_component_id; ?>" />

    <h2><?php echo $translation->get("contact_field_headline"); ?></h2>
    <ul class="toolbar_menu">
        <?= button("new", $translation->get("new_level"), $formname, "loadCard('new_line_contactform_level', true)", "", FALSE); ?>
        <?= button("new", $translation->get("new_section"), $formname, "loadCard('new_line_contactform_section', true)", "", FALSE); ?>
        <?= button("new", $translation->get("new"), $formname, "loadCard('new_line_contactform', true)", "", FALSE); ?>
        <?= button("edit", $translation->get("edit"), $formname, "loadCard('edit_line_contactform')", "", FALSE); ?>
        <?= button("delete", $translation->get("delete"), $formname, "loadCard('delete_line_contactform', false, '{$translation->get('delete_contactform_field_confirm')}')", "", FALSE); ?>

        <?= button("up", $translation->get("go_up"), $formname, "loadCard('moveup_line_contactform')", "", FALSE); ?>
        <?= button("down", $translation->get("go_down"), $formname, "loadCard('movedown_line_contactform')", "", FALSE); ?>

    </ul>
    <div class="clearfix"></div>
         <div class="tab">
            <?
                $query = "SELECT * FROM contactform_steps where contactform_id = ".$input_id;
                
                $result = @mysqli_query($GLOBALS['mysql_con'], $query);
                $i = 0;
                while($row    = mysqli_fetch_array($result)){
                    ?>
                    <button class="tablinks" onclick="openTab(event, 'tab<?=$row['id']?>')" <?php if($i == 0){ ?> id="defaultOpen" <?php } ?> ><?= $row['name'];?></button>
                    
                    <? $i ++; } ?>
        </div>
        
   <!-- tab div -->

 
 

   <?
    $query = "SELECT * FROM contactform_steps where contactform_id = ".$input_id;
 
    $result = @mysqli_query($GLOBALS['mysql_con'], $query);
     while($row    = mysqli_fetch_array($result)){
    ?>
        <div id="tab<?=$row['id']?>" class="tabcontent">
            
                <div class="tab">
                    <?
                        $query = "SELECT * FROM contactform_section where contactform_id = ".$input_id.'';
                        
                        $result = @mysqli_query($GLOBALS['mysql_con'], $query);
                        $i = 0;
                        while($row    = mysqli_fetch_array($result)){
                            ?>
                            <button class="tablinks" onclick="openSection(event, 'tab_section_<?=$row['id']?>')" <?php if($i == 0){ ?> id="defaultOpen2" <?php } ?> ><?= $row['name'];?></button>
                            
                            <? $i ++; } ?>
                </div>
                
        <!-- tab div -->

        </div>
    <?php } ?>
</form>