<?php declare(strict_types=1);

// needs globals $qrbCfg, $qrbXl

// included by index.php

// POSTs to target "saveQrBillsConfiguration" in QrBillsSaveCfg.

?>

          <form action="#saveCfg" method="post">
<?php    
    if ($qrbCfg->getCreatePdf()) {    
?>
            <div class="highlight">
              <div id="pdfDetails">
              
                <div class="row">
                  <div class="col-4">
                    <h4>
<?php   print $qrbApi->xl('cfg.currency.title'); ?>
                    </h4>
                  </div>
                  <div class="col-8 cfg">
                    <div class="cfgItem">
                      <div class="form-check">
                        <input class="form-check-input" type="radio" name="currency" id="currencyCHF"
<?php
        print 'value="' . QrbProfileConfiguration::CHF . '"';
        if ($qrbCfg->getCurrency() == QrbProfileConfiguration::CHF) print 'checked="checked"';
?>
                        />
                        <label class="form-check-label" for="currencyCHF">
<?php   print $qrbApi->xl('cfg.currency.CHF'); ?>
                        </label>
                      </div>
                      <div class="form-check">
                        <input class="form-check-input" type="radio" name="currency" id="currencyEUR"
<?php
        print 'value="' . QrbProfileConfiguration::EUR . '"';
        if ($qrbCfg->getCurrency() == QrbProfileConfiguration::EUR) print 'checked="checked"';
?>
                        />
                        <label class="form-check-label" for="currencyEUR">
<?php   print $qrbApi->xl('cfg.currency.EUR'); ?>
                        </label>
                      </div>
                    </div>
                  </div>
                </div>

                <div class="row">
                  <div class="col-4">
                    <h4>
<?php   print $qrbApi->xl('cfg.printAmount.title'); ?>
                    </h4>
                  </div>
                  <div class="col-8 cfg">
                    <div class="cfgItem">
                      <div class="form-check">
                        <input class="form-check-input"  type="radio" name="printAmount" id="NoAmount"
<?php
        print 'value="' . QrbProfileConfiguration::NO_AMOUNT . '"';
        if ($qrbCfg->getPrintAmount() == QrbProfileConfiguration::NO_AMOUNT) print 'checked="checked"';
?>
                        <input >
                        <label class="form-check-label" for="NoAmount">
<?php   print $qrbApi->xl('cfg.printAmount.no'); ?>
                        </label>
                      </div>
                      <div class="form-check">
                        <input class="form-check-input" type="radio" name="printAmount" id="IndividualAmount"
<?php
        print 'value="' . QrbProfileConfiguration::INDIVIDUAL_AMOUNT . '"';
        if ($qrbCfg->getPrintAmount() == QrbProfileConfiguration::INDIVIDUAL_AMOUNT) print 'checked="checked"';
?>
                        />
                        <label for="IndividualAmount">
<?php   print $qrbApi->xl('cfg.printAmount.individual'); ?>
                        </label>
                      </div>
                      <div class="form-check">
                        <input class="form-check-input" type="radio" name="printAmount" id="GlobalAmount"
<?php
        print 'value="' . QrbProfileConfiguration::GLOBAL_AMOUNT . '"';
        if ($qrbCfg->getPrintAmount() == QrbProfileConfiguration::GLOBAL_AMOUNT) print 'checked="checked"';
?>
                        />
                        <label class="form-check-label" for="GlobalAmount">
<?php   print $qrbApi->xl('cfg.printAmount.global'); ?>
                        </label>
                      </div>
                    </div>
                    <div class="cfgItem">
                      <input class="form-control" type="number" name="amount" id="Amount" min="0.00" max="500.00" step="0.01"
<?php   print 'value="' . number_format($qrbCfg->getAmount(), 2, '.', '') . '"'; ?>
                      />
                    </div>
                  </div>
                </div>

<?php   
        if ($qrbCfg->getPrintPaymentSlip()) {    
?>
                <div id="paymentSlip">

                  <div class="row">
                    <div class="col-4">
                      <h4>
<?php       print $qrbApi->xl('cfg.paymentSlip.printUltimateDebtor.title'); ?>
                      </h4>
                    </div>
                    <div class="col-8 cfg">
                      <div class="cfgItem">
                        <div class="form-check">
                          <input class="form-check-input" type="radio" name="addDebtor" id="no" value="false"
<?php       if (!$qrbCfg->getAddDebtor()) print 'checked="checked"'; ?>
                          />
                          <label class="form-check-label" for="no">
<?php       print $qrbApi->xl('cfg.paymentSlip.printUltimateDebtor.no'); ?>
                          </label>
                        </div>
                        <div class="form-check">
                          <input class="form-check-input" type="radio" name="addDebtor" id="yes" value="true"
<?php       if ($qrbCfg->getAddDebtor()) print 'checked="checked"'; ?>
                          />
                          <label class="form-check-label" for="yes">
<?php       print $qrbApi->xl('cfg.paymentSlip.printUltimateDebtor.yes'); ?>
                          </label>
                        </div>
                      </div>
                    </div>
                  </div>

                  <div class="row">
                    <div class="col-4">
                      <h4>
<?php       print $qrbApi->xl('cfg.paymentSlip.appendReference.title'); ?>
                      </h4>
                    </div>
                    <div class="col-8 cfg">
                      <div class="cfgItem">
                        <div class="form-check">
                          <input class="form-check-input" type="radio" name="addRefToAddInfo" id="no" value="false"
<?php       if (!$qrbCfg->getAddRefToAddInfo()) print 'checked="checked"'; ?>
                          />
                          <label class="form-check-label" for="no">
<?php       print $qrbApi->xl('cfg.paymentSlip.appendReference.no'); ?>
                          </label>
                        </div>
                        <div class="form-check">
                          <input class="form-check-input" type="radio" name="addRefToAddInfo" id="yes" value="true"
<?php       if ($qrbCfg->getAddRefToAddInfo()) print 'checked="checked"; '?>
                          />
                          <label class="form-check-label" for="yes">
<?php       print $qrbApi->xl('cfg.paymentSlip.appendReference.yes'); ?>
                          </label>
                        </div>
                      </div>
                    </div>
                  </div>
                  
                </div>
<?php
        }
?>
              </div>
            </div>
<?php
    }
?>

            <div class="highlight">
<?php    
    // only show choice for sending e-mail if a PDF is created (otherwise it must be true anyway)
    if ($qrbCfg->getCreatePdf()) {    
?>

              <div class="row">
                <div class="col-4">
                  <h3>
<?php   print $qrbApi->xl('cfg.mail.sendMail.title'); ?>
                  </h3>
                </div>
                <div class="col-8 cfg">
                  <div class="cfgItem">
                    <div class="form-check">
                      <input class="form-check-input" type="radio" name="sendMail" id="no" value="false"
<?php   if (!$qrbCfg->getSendMail()) print 'checked="checked"'; ?>
                      />
                      <label class="form-check-label" for="no">
<?php   print $qrbApi->xl('cfg.mail.sendMail.no'); ?>
                      </label>
                    </div>
                    <div class="form-check">
                      <input class="form-check-input" type="radio" name="sendMail" id="yes" value="true"
<?php   if ($qrbCfg->getSendMail()) print 'checked="checked"'; ?>
                      />
                      <label class="form-check-label" for="yes">
<?php   print $qrbApi->xl('cfg.mail.sendMail.yes'); ?>
                      </label>
                    </div>
                  </div>
                </div>
              </div>
<?php    
    }
?>

<?php
    if ($qrbCfg->getSendMail()) {    
?>
              <div id="eMail">
              
                <div class="row">
                  <div class="col-4">
                    <h4>
<?php   print $qrbApi->xl('cfg.mail.testMail.title'); ?>
                      <span class="iconPopover">
                        <a class="btn btn-dark" tabindex="0" role="button" data-bs-toggle="popover" data-bs-trigger="focus" data-bs-title="
<?php   print $qrbApi->xl('cfg.mail.testMail.title'); ?>
                          " data-bs-content="
<?php   print $qrbApi->xl('cfg.mail.testMail.info'); ?>
                          ">
                          i
                        </a>
                      </span>
                    </h4>
                  </div>
                  <div class="col-8 cfg">
                    <div class="cfgItem">
                      <input class="form-control " type="text" name="presetMail" id="presetMail"
<?php   print 'value="' . ($qrbCfg->getPresetMail() ) . '"'; ?>
                       />
                    </div>
                  </div>
                </div>

                <div class="row">
                  <div class="col-4">
                    <h4>
<?php   print $qrbApi->xl('cfg.mail.sleepAfterSend.title'); ?>
                      <span class="iconPopover">
                        <a class="btn btn-dark" tabindex="0" role="button" data-bs-toggle="popover" data-bs-trigger="focus" data-bs-title="
<?php   print $qrbApi->xl('cfg.mail.sleepAfterSend.title'); ?>
                          " data-bs-content="
<?php   print $qrbApi->xl('cfg.mail.sleepAfterSend.info'); ?>
                          ">
                          i
                        </a>
                      </span>
                    </h4>
                  </div>
                  <div class="col-8 cfg">
                    <div class="cfgItem">
<?php   print $qrbApi->xl('cfg.mail.sleepAfterSend.range'); ?>
                    </div>
                    <div class="cfgItem">
                      <input class="form-control" type="number" id="sleepAfterSend" name="sleepAfterSend" min="1" max="20"
<?php   print 'value="' . ($qrbCfg->getSleepAfterSend() / SLEEP_FACTOR) . '"'; ?>
                      />
                    </div>
                  </div>
                </div>
                
              </div>
<?php   
    }
?>
            </div>

            <div class="highlight">
            
              <div class="row">
                <div class="col-4">
                  <h3>
<?php   
    print $qrbApi->xl('cfg.defaultLanguage.title'); 
?>
                    <span class="iconPopover">
                      <a class="btn btn-dark" tabindex="0" role="button" data-bs-toggle="popover" data-bs-trigger="focus" data-bs-title="
<?php
    print $qrbApi->xl('cfg.defaultLanguage.title'); 
?>
                        " data-bs-html="true" data-bs-content="
<?php
    print $qrbApi->xl('cfg.defaultLanguage.info'); 
?>
                        ">
                        i
                      </a>
                    </span>
                  </h4>
                </div>
                <div class="col-8 cfg">
                  <div class="cfgItem">
                    <?php $defaultLanguage = $qrbCfg->getDefaultLanguage(); ?>
                    <select class="form-select" name="defaultLang" onchange="checkAddLang()" id="defaultLang" size="1">
                      <option value="de" 
<?php
    if ($defaultLanguage == "de") print 'selected' 
?>
                      >
<?php
    print $qrbApi->xl('cfg.defaultLanguage.de'); 
?>
                      </option>
                      <option value="en" 
<?php
    if ($defaultLanguage == "en") print 'selected' 
?>
                      >
<?php
    print $qrbApi->xl('cfg.defaultLanguage.en'); 
?>
                      </option>
                      <option value="fr"
<?php
    if ($defaultLanguage == "fr") print 'selected' 
?>
                      >
<?php
    print $qrbApi->xl('cfg.defaultLanguage.fr'); 
?>
                      </option>
                      <option value="it"
<?php
    if ($defaultLanguage == "it") print 'selected' 
?>
                      >
<?php
    print $qrbApi->xl('cfg.defaultLanguage.it'); 
?>
                      </option>
                    </select>
                  </div>
                </div>
              </div>

              <div class="row">
                <div class="col-4">
                  <h3>
<?php
    print $qrbApi->xl('cfg.multiLanguageSupport.title'); 
?>
                  </h3>
                </div>
                <div class="col-8 cfg">
                  <div class="cfgItem">
                    <div class="form-check">
                      <input class="form-check-input" type="radio" name="multiLang" id="no" value="false"
<?php
    if (!$qrbCfg->getMultiLanguage()) print 'checked="checked"'; 
?>
                      />
                      <label class="form-check-label" for="no">
<?php
    print $qrbApi->xl('cfg.multiLanguageSupport.no'); 
?>
                      </label>
                    </div>
                    <div class="form-check">
                      <input class="form-check-input" type="radio" name="multiLang" id="yes" value="true"
<?php
    if ($qrbCfg->getMultiLanguage()) print 'checked="checked"'; 
?>
                      />
                      <label class="form-check-label" for="yes">
<?php
    print $qrbApi->xl('cfg.multiLanguageSupport.yes'); 
?>
                      </label>
                    </div>
                  </div>
                </div>
              </div>

<?php
    if ($qrbCfg->getMultiLanguage()) {    
?>
              <div id="multiLang">
              
                <div class="row">
                  <div class="col-4">
                    <h4>
<?php   print $qrbApi->xl('cfg.multiLanguageSupport.additionalLanguages.title'); ?>
                      <span class="iconPopover">
                        <a class="btn btn-dark" tabindex="0" role="button" data-bs-html="true"  data-bs-toggle="popover" data-bs-trigger="focus" data-bs-title="
<?php   print $qrbApi->xl('cfg.multiLanguageSupport.additionalLanguages.title'); ?>
                          " data-bs-content="
<?php   print $qrbApi->xl('cfg.multiLanguageSupport.additionalLanguages.info'); ?>
                          ">
                          i
                        </a>
                      </span>
                    </h4>
                  </div>
                  <div class="col-8 cfg">
                    <div class="cfgItem">
                    
                      <div class="form-check">
                        <input class="form-check-input" type="checkbox" id="addLang_de" name="addLang_de" value="de"
<?php    
        if ($qrbCfg->getDefaultLanguage() == "de") print 'disabled'; 
        if (in_array("de", $qrbCfg->getAdditionalLanguages(), true)) print 'checked="checked"';
?>
                        />
                        <label class="form-check-label" for="addLang_de">
<?php   print $qrbApi->xl('cfg.multiLanguageSupport.additionalLanguages.de'); ?>
                        </label>
                      </div>
                      
                      <div class="form-check">
                        <input class="form-check-input" type="checkbox" id="addLang_en" name="addLang_en" value="en"
<?php    
        if ($qrbCfg->getDefaultLanguage() == "en") print 'disabled'; 
        if (in_array("en", $qrbCfg->getAdditionalLanguages(), true)) print 'checked="checked"';
?>
                        />
                        <label class="form-check-label" for="addLang_en">
<?php   print $qrbApi->xl('cfg.multiLanguageSupport.additionalLanguages.en'); ?>
                        </label>
                      </div>

                      <div class="form-check">
                        <input class="form-check-input" type="checkbox" id="addLang_fr" name="addLang_fr" value="fr"
<?php    
        if ($qrbCfg->getDefaultLanguage() == "fr") print 'disabled'; 
        if (in_array("fr", $qrbCfg->getAdditionalLanguages(), true)) print 'checked="checked"';
?>
                        />
                        <label class="form-check-label" for="addLang_fr">
<?php   print $qrbApi->xl('cfg.multiLanguageSupport.additionalLanguages.fr'); ?>
                        </label>
                      </div>

                      <div class="form-check">
                        <input class="form-check-input" type="checkbox" id="addLang_it" name="addLang_it" value="it"
<?php    
        if ($qrbCfg->getDefaultLanguage() == "it") print 'disabled'; 
        if (in_array("it", $qrbCfg->getAdditionalLanguages(), true)) print 'checked="checked"';
?>
                        />
                        <label class="form-check-label" for="addLang_it">
<?php   print $qrbApi->xl('cfg.multiLanguageSupport.additionalLanguages.it'); ?>
                        </label>
                      </div>
                      
                    </div>
                  </div>
                </div>
                
              </div>
<?php
    }
?>
            </div>

                <div class="row">
                  <div class="col-4">
                  </div>
                  <div class="col-8">
            <div id="saveCfg" class="SubmitButton center">
              <input type="submit" class="btn btn-dark" name="saveQrBillsConfiguration"
<?php
    print ' value="' . $qrbApi->xl('cfg.submit') . '" '; 
?>
              />
            </div>
                  </div>
                </div>
          </form>
