<?php
    /*
    * copyright (c) 2013-2021 Heliac Technologies
    * license http://opensource.org/licenses/gpl-license.php GNU GPL v3 
    *
    * linee guida per l'utilizzo del logo http://www.geecom.org/index.php?alias=linee-guida-per-luso-del-logo-geecom
    */

    $arrayColori = array(""=>"Trasparente","bg-primary"=>"Primary","bg-secondary"=>"Secondary","bg-success"=>"Success","bg-info"=>"Info","bg-warning"=>"Warning","bg-danger"=>"Danger","bg-light"=>"Light","bg-dark"=>"Dark","bg-white"=>"Bianco");
    $coloreMenu = array("text-light"=>"Chiaro","text-dark"=>"Scuro");
?>
<h4 class="mb-4 title">Footer</h4>

<ul class="nav nav-tabs" id="myTab" role="tablist">
    <?php 
        foreach($lingue as $lingua) {
            if(isset($_GET["lingua"]) && $_GET["lingua"]==$lingua) {
                echo"<li class=\"nav-item\" role=\"presentation\">
                    <a class=\"nav-link active\" data-toggle=\"tab\" href=\"#footer$lingua\" role=\"tab\" aria-controls=\"footer$lingua\" aria-selected=\"true\">$lingua</a>
                </li>";
            }
            else if($impostazioni["linguaSito"]==$lingua && !isset($_GET["lingua"])) {
                echo"<li class=\"nav-item\" role=\"presentation\">
                    <a class=\"nav-link active\" data-toggle=\"tab\" href=\"#footer$lingua\" role=\"tab\" aria-controls=\"footer$lingua\" aria-selected=\"true\">$lingua</a>
                </li>";
            }
            else {
                $linguaLetteraMaiuscola = ucfirst($lingua);
                $classe   = ($impostazioniLingue["impostazioni$linguaLetteraMaiuscola"] == "si") ? "nav-link" : "nav-link disabled";
                $tabIndex = ($impostazioniLingue["impostazioni$linguaLetteraMaiuscola"] == "si") ? "" : "tabindex=\"-1\"";
                $stringaCollegamentoTab = ($impostazioniLingue["impostazioni$linguaLetteraMaiuscola"] == "si") ? "href=\"#footer$lingua\" data-toggle=\"tab\"" : "";
                echo"<li class=\"nav-item\" role=\"presentation\">
                    <a class=\"$classe\" $tabIndex data-toggle=\"tab\" href=\"#footer$lingua\" role=\"tab\" aria-controls=\"footer$lingua\" aria-selected=\"true\">$lingua</a>
                </li>";
            }
        }
    ?>
</ul>
<div class="tab-content" id="myTabContent">
    <?php 
        foreach($lingue as $lingua) {
            $linguaLetteraMaiuscola = ucfirst($lingua);
           
            $footer = $geecomDb->leggiSingolaRiga("geecD_footer",$lingua,"lingua");
            if(isset($_GET["lingua"]) && $_GET["lingua"]==$lingua) {
                $classeDiv = "show active";
            }
            else if($impostazioni["linguaSito"]==$lingua && !isset($_GET["lingua"])) {
                $classeDiv = "show active";
            }
            else {
                $classeDiv = "";
            }
            ?>
            <div class="tab-pane fade  <?php echo $classeDiv ?>" id="footer<?php echo $lingua ?>" role="tabpanel" aria-labelledby="<?php echo $lingua ?>">
                <form class="form-horizontal" role="form" name="formImpostazioniFooter<?php echo $linguaLetteraMaiuscola ?>" action="../controller/controllerImpostazioni.php" method="post" enctype="multipart/form-data">
                    <input type="text" class="d-none" name="operazione" value="aggiornaImpostazioniFooter">
                    <input type="text" class="d-none" name="id" value="<?php echo $footer["id"] ?>">
                    <input type="text" class="d-none" name="lingua" value="<?php echo $footer["lingua"] ?>">
                    
                    <div class="row mt-5">
                        <div class="col-12">
                            <h5>Footer superiore</h5>
                            <hr>
                        </div>

                        <div class="col-12">
                            <div class="form-row">
                                <div class="form-group col-md-4">
                                    <label class="d-block">Attiva footer superiore</label>
                                    <input type="checkbox" id="attivaFooterSuperiore<?php echo $linguaLetteraMaiuscola ?>" name="attivaFooterSuperiore" class="js-switch" value="si" <?php
                                            if($footer["attivaFooterSuperiore"]=="si") { // se il valore = si aggiunge la parola checked
                                              echo"CHECKED";
                                           }
                                        ?> />
                                </div>
                            </div>
                            <div class="form-row">
                                <div class="form-group col-lg-4">
                                    <label for="InputFile" >Sfondo footer superiore</label>
                                    <select class="form-control" name="coloreFooterSuperiore">
                                    <?php 
                                        foreach($arrayColori as $classe=>$colore) {
                                            if($footer["coloreFooterSuperiore"]==$classe) {
                                                echo"<option value=\"$classe\" selected>$colore</option>";
                                            }
                                            else {
                                                echo"<option value=\"$classe\">$colore</option>";
                                            }
                                        }
                                    ?>
                                    </select>
                                </div>

                                <div class="form-group col-lg-4">
                                    <label for="InputFile">Colore testi footer superiore</label>
                                    <select class="form-control" name="coloreTestiMenu">
                                    <?php 
                                        foreach($coloreMenu as $classe=>$colore) {
                                            if($footer["coloreTestiMenu"]==$classe) {
                                                echo"<option value=\"$classe\" selected>$colore</option>";
                                            }
                                            else {
                                                echo"<option value=\"$classe\">$colore</option>";
                                            }
                                        }
                                    ?>
                                    </select>
                                </div>

                                <div class="form-group col-lg-4">
                                    <label for="InputFile" >Numero colonne</label>
                                    <select class="form-control" name="numeroColonne">
                                        <?php 
                                          for($i=1;$i<=4;$i++) {
                                              if($footer["numeroColonne"]==$i) {
                                                  echo"<option value=\"$i\" selected>{$i}</option>";					
                                              }
                                              else {
                                                  echo"<option value=\"$i\">{$i}</option>";
                                              }
                                          }
                                        ?>
                                    </select>
                                </div>
                            </div>
                        </div>

                        <div class="col-12 mt-5">
                            <h5>Contenuto colonne footer superirore</h5>
                            <hr>
                        </div>

                        <div class="col-12">
                            <div class="form-row">
                                <div class="form-group col-lg-6">
                                    <label for="InputFile">Prima colonna</label>
                                    <select class="form-control" name="colonna1">
                                        <option value=0>Seleziona il menu</option>
                                        <?php 
                                          $queryNomiTag = "SELECT * FROM geecD_menu";
                                          $risNomi = $geecomDb->eseguiQueryLettura($queryNomiTag);
                                          while($tag = $risNomi->fetch_assoc()) {
                                              if($footer["colonna1"]==$tag["id"]) {
                                                  echo"<option value=\"{$tag["id"]}\" selected>{$tag["nome"]}</option>";						
                                              }
                                              else {
                                                  echo"<option value=\"{$tag["id"]}\">{$tag["nome"]}</option>";
                                              }
                                          }
                                        ?>
                                    </select>
                                </div>

                                <div class="form-group col-lg-6">
                                    <label for="InputFile" >Titolo colonna</label>
                                    <input type=text class="form-control" name="titoloColonna1" placeholder="Titolo prima colonna" value="<?php echo $footer["titoloColonna1"]; ?>"/>
                                </div>
                            </div>

                            <div class="form-row">
                                <div class="form-group col-lg-6">
                                    <label for="InputFile" >Seconda colonna</label>
                                    <select class="form-control" name="colonna2">
                                        <option value=0>Seleziona il menu</option>
                                    <?php 
                                      $queryNomiTag = "SELECT * FROM geecD_menu";
                                      $risNomi = $geecomDb->eseguiQueryLettura($queryNomiTag);
                                      while($tag = $risNomi->fetch_assoc()) {
                                          if($footer["colonna2"]==$tag["id"]) {
                                              echo"<option value=\"{$tag["id"]}\" selected>{$tag["nome"]}</option>";						
                                          }
                                          else {
                                              echo"<option value=\"{$tag["id"]}\">{$tag["nome"]}</option>";
                                          }
                                      }
                                    ?>
                                    </select>
                                </div>

                                <div class="form-group col-lg-6">
                                    <label for="InputFile" >Titolo colonna</label>
                                    <input type=text class="form-control" name="titoloColonna2" placeholder="Titolo seconda colonna"  value="<?php echo $footer["titoloColonna2"]; ?>"/>
                                </div>
                            </div>

                            <div class="form-row">
                                <div class="form-group col-lg-6">
                                    <label for="InputFile" >Terza colonna</label>
                                    <select class="form-control" name="colonna3">
                                        <option value=0>Seleziona il menu</option>
                                        <?php 
                                          $queryNomiTag = "SELECT * FROM geecD_menu";
                                          $risNomi = $geecomDb->eseguiQueryLettura($queryNomiTag);
                                          while($tag = $risNomi->fetch_assoc()) {
                                            if($footer["colonna3"]==$tag["id"]) {
                                                  echo"<option value=\"{$tag["id"]}\" selected>{$tag["nome"]}</option>";						
                                              }
                                              else {
                                                  echo"<option value=\"{$tag["id"]}\">{$tag["nome"]}</option>";
                                              }
                                          }
                                        ?>
                                    </select>
                                </div>
                                <div class="form-group col-lg-6">    
                                    <label for="InputFile" >Titolo colonna</label>
                                    <input type=text class="form-control" name="titoloColonna3" placeholder="Titolo terza colonna"  value="<?php echo $footer["titoloColonna3"]; ?>" />
                                </div>
                            </div>


                            <div class="form-row">
                                <div class="form-group col-lg-6">
                                    <label for="InputFile" >Quarta colonna</label>
                                    <select class="form-control" name="colonna4">
                                        <option value=0>Seleziona il menu</option>
                                    <?php 
                                      $queryNomiTag = "SELECT * FROM geecD_menu";
                                      $risNomi = $geecomDb->eseguiQueryLettura($queryNomiTag);
                                      while($tag = $risNomi->fetch_assoc()) {
                                          if($footer["colonna4"]==$tag["id"]) {
                                              echo"<option value=\"{$tag["id"]}\" selected>{$tag["nome"]}</option>";						
                                          }
                                          else {
                                              echo"<option value=\"{$tag["id"]}\">{$tag["nome"]}</option>";
                                          }
                                      }
                                    ?>
                                    </select>
                                </div>
                                <div class="form-group col-lg-6">
                                    <label for="InputFile" >Titolo colonna</label>
                                    <input type=text class="form-control" name="titoloColonna4" placeholder="Titolo quarta colonna"  value="<?php echo $footer["titoloColonna4"]; ?>"/>
                                </div>
                            </div>
                        </div>
                    </div>

                    <div class="row mt-5">
                        <div class="col-12">
                            <h5>Footer inferiore</h5>
                            <hr>
                        </div>

                        <div class="form-group col-lg-4">
                            <label for="InputFile" >Sfondo footer inferiore</label>
                            <select class="form-control" name="coloreFooterInferiore">
                            <?php 
                                foreach($arrayColori as $classe=>$colore) {
                                    if($footer["coloreFooterInferiore"]==$classe) {
                                        echo"<option value=\"$classe\" selected>$colore</option>";
                                    }
                                    else {
                                        echo"<option value=\"$classe\">$colore</option>";
                                    }
                                }
                            ?>
                            </select>
                        </div>

                        <div class="col-sm-12">
                            <h6>Testo del footer</h6>
                            <textarea class="form-control tiny" rows="15" id="testoFooter<?php echo $linguaLetteraMaiuscola ?>" name="testoFooter"><?php echo $footer["testo"] ?></textarea>
                        </div>
                    </div>
                    <button type="button" class="btn btn-primary float-right mt-4" onclick="document.formImpostazioniFooter<?php echo $linguaLetteraMaiuscola ?>.submit()"><i class="fas fa-check"></i> Salva </button>                    
                </form>
            </div>
            <?php
        }
    ?>
</div>