{if $action == ''}
<!doctype html>
<html lang="de">
   <head>
      <meta charset="utf-8">
      {if $create_edit == ''}
      <title>JU & MI Finazen erfassen</title>
      {else}
      <title>JU & MI Finazen bearbeiten</title>
      {/if}
      <meta name="viewport" content="width=device-width, initial-scale=1">
      <link href="../bootstrap/node_modules/bootstrap/dist/css/bootstrap.min.css" rel="stylesheet">
      <script src="../bootstrap/node_modules/bootstrap/dist/js/bootstrap.bundle.min.js"></script>
      <!-- nochmals bootstrap.css mit Erweiterungen vom Dashboard -->
      <link href="css/styles.css" rel="stylesheet" />
      <!-- data Table: https://datatables.net/ -->
      <script src="../bootstrap/data-table/jquery.min.js"></script>
      <link rel="stylesheet" href="../bootstrap/data-table/dataTables.bootstrap5.min.css">
      </style>
      <link rel="stylesheet" href="../bootstrap/data-table/rowReorder.dataTables.min.css">
      </style>
      <script type="text/javascript" src="../bootstrap/data-table/jquery.dataTables.min.js"></script>
      <script type="text/javascript" src="../bootstrap/data-table/dataTables.rowReorder.min.js"></script>
      <script type="text/javascript" src="../bootstrap/data-table/dataTables.bootstrap5.min.js"></script>
      <!-- icons in nav-->
      <script src="js/all.js" crossorigin="anonymous"></script>
      <link rel="stylesheet" href="../bootstrap/node_modules/bootstrap-icons/font/bootstrap-icons.css">
      <script src="../jquery/jquery-3.4.1.min.js"></script>
      <!-- jQuery UI CSS
         <script src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.11.2/jquery-ui.min.js"></script>
         -->
      <link rel="stylesheet" href="../jquery/jquery-ui.css">
      <script src="../jquery/jquery-ui.js"></script>
      <!--<script type="text/javascript" charset="utf-8" language="javascript" src="../js/file_upload/DT_bootstrap.js"></script>-->
      <script type="text/javascript">
         $(function() {
             $(".datepicker").datepicker({
             prevText: '&#x3c; zur&uuml;ck', prevStatus: '',
             prevJumpText: '&#x3c;&#x3c;', prevJumpStatus: '',
             changeMonth: true,
             changeYear: true,
             nextText: 'Vor &#x3e;', nextStatus: '',
             nextJumpText: '&#x3e;&#x3e;', nextJumpStatus: '',
             currentText: 'Heute', currentStatus: '',
             todayText: 'Heute', todayStatus: '',
             clearText: '-', clearStatus: '',
             closeText: 'schlie&szlig;en', closeStatus: '',
             monthNames: ['Januar','Februar','M&auml;rz','April','Mai','Juni','Juli','August','September','Oktober','November','Dezember'],
             monthNamesShort: ['Jan','Feb','M&auml;r','Apr','Mai','Jun','Jul','Aug','Sep','Okt','Nov','Dez'],
             dayNames: ['Sonntag','Montag','Dienstag','Mittwoch','Donnerstag','Freitag','Samstag'],
             dayNamesShort: ['So','Mo','Di','Mi','Do','Fr','Sa'],
             dayNamesMin: ['So','Mo','Di','Mi','Do','Fr','Sa'],
             weekHeader: 'Wo',
             weekStatus: 'Woche des Monats',
             showMonthAfterYear: false,
             showOn: 'focus',
             firstDay: 1,
             numberOfMonths : 1,
             yearRange: "c-5:+5",
             showButtonPanel : true,
             altField : "#datepicker_input",
             dateFormat : "dd.mm.yy",
             showWeek: true
             });
             $.datepicker._gotoToday = function(id) {
         $(id).datepicker('setDate', new Date()).datepicker('hide').blur();
             }

         });
      </script>
      <script type="text/javascript" src="../js/file_upload/vpb_uploader_finanzen.js"></script>
      <script type="text/javascript">$(document).ready(function()
         {
         	// Call the main function
         	new vpb_multiple_file_uploader
         	({
         		vpb_form_id: "form_id", // Form ID
         		autoSubmit: true,
         		vpb_server_url: "../controller/admin_finanzen.php"
         	});
         });
      </script>
      <link href = "../jquery/jquery-ui-themes-1.13.2/jquery-ui.css" rel = "stylesheet">
      <style>
         body {
         font-family:Verdana, Geneva, sans-serif;
         }
         span{
         color:red;
         cursor:pointer;
         }
      </style>
   </head>
   <!--<body onload="if(document.erfassen)document.erfassen.{$umfrageerf_focus}.focus();return false;">-->
   <body class="sb-nav-fixed">
      <div id="navtop"></div>
      {literal}
      <script>
         $(function(){
           // im Navbar muss der toggle in der Callbackfunktion definiert werden. Sonst findet jquery getelementbyID nicht
           $("#navtop").load('navtop.php', null, function(){$.getScript('js/scripts.js');});
           $("#navleft").load("nav.php");
           $("#footer").load("footer.php");
         });
      </script>
      {/literal}
      <div id="layoutSidenav">
         <!-- Navigation left -->
         <div id="navleft"></div>
         <div id="layoutSidenav_content">
            <main>
               <div class="container-fluid">
                  <form name="form_id" id="form_id" action="javascript:void(0);" enctype="multipart/form-data">
                     <div class="card">
                        <div class="card-header">
                           <i class="fas fa-edit me-1"></i>
                           {if $create_edit == ''}
                           Finanzen erfassen
                           {else}
                           Finanzen bearbeiten
                           {/if}
                     <div class="d-lg-none">
                        <font color="red">Querformat für Mobilgeräte</font>
                     </div>
                        </div>
                        <div class="card-body">
                           <div class="row">
                              <div class="row mt-2 mb-2">
                                 <div class="col-12 col-md-4">Datum:</div>
                                 <div class="col-12 col-md-8">
                                    <input type="text" class="datepicker form-control" name="datum" id="datum" value="{$finanzen_datum}" required>
                                 </div>
                              </div>
                              <div class="row mt-2 mb-2">
                                 <div class="col-12 col-md-4">Beschreibung:</div>
                                 <div class="col-12 col-md-8">
                                    <input type="text" id="beschreibung" class="form-control rounded-right" value="{$finanzen_beschreibung}" required>
                                 </div>
                              </div>
                              <div class="row mt-2 mb-2">
                                 <div class="col-12 col-md-4">Firma:</div>
                                 <div class="col-12 col-md-8">
                                    <input type="text" id="firma"  class="form-control rounded-right" value="{$finanzen_firma}">
                                 </div>
                              </div>
                              <div class="row mt-2 mb-2">
                                 <div class="col-12 col-md-4">Art:</div>
                                 <div class="col-12 col-md-8">
                                    <select name="art"class="form-control" id="art">
                                    <option value="E" {if $finanzen_art == "E"} selected {/if}>Einnahme</option>
                                    <option value="A" {if $finanzen_art == "A"} selected {/if}>Ausgabe</option>
                                    </select>
                                 </div>
                              </div>
                              <div class="row mt-2 mb-2">
                                 <div class="col-12 col-md-4">Betrag:</div>
                                 <div class="col-12 col-md-8">
                                    <input type="number" min="1" step="any" id="betrag" class="form-control rounded-right" value="{$finanzen_betrag}" required>
                                 </div>
                              </div>
                              <div class="row mt-2 mb-2">
                                 <div class="col-12 col-md-4">Bemerkung:</div>
                                 <div class="col-12 col-md-8">
                                    <input type="text" id="bemerkung"  class="form-control rounded-right" value="{$finanzen_bemerkung}">
                                 </div>
                              </div>
                              {if $create_edit != ''}
                              <div class="row mt-2 mb-2">
                                 <div class="col-12 col-md-4">Dateien:</div>
                                 <div class="col-12 col-md-8">
                                    <div class="form-group">
                                       <table class="table table-striped table-bordered" id="curdoks">
                                          <thead>
                                             <tr>
                                                <th style="color:blue; text-align:center;">Datei</th>
                                                <th  class="d-none d-lg-table-cell" style="color:blue; text-align:center;">Uploaddatum</th>
                                                <th style="color:blue; text-align:center;">Aktion</th>
                                             <tr>
                                          </thead>
                                          <tbody>
                                             {section name=table_data2 loop=$table_data2}
                                             <tr>
                                                <td><a href="{$table_data2[table_data2].filename}" target="_new">{$table_data2[table_data2].originalname}</a></td>
                                                <td class="d-none d-lg-table-cell">{$table_data2[table_data2].uploaddatum}</td>
                                                <td><a class="btn btn-danger  btn-rounded btn-icon btn-sm" onclick="delBelegFile({$table_data2[table_data2].id})"><i class="fa fa-trash" style="width:18px;"></i></a></td>
                                             </tr>
                                             {/section}
                                          </tbody>
                                       </table>
                                    </div>
                                 </div>
                              </div>
                              {/if}
                              <div class="row mt-2 mb-2">
                                 <label for="formFile" class="form-label">
                                    <div class="col-12 col-md-4">Belege:</div>
                                    <div class="col-12col-md-8">
                                       <input class="form-control" type="file" name="vasplus_multiple_files" id="vasplus_multiple_files" multiple="multiple">
                                    </div>
                                 </label>
                              </div>
                              <table class="table table-striped table-bordered" id="add_files">
                                 <thead>
                                    <tr>
                                       <th style="color:blue; text-align:center;">Datei</th>
                                       <th style="color:blue; text-align:center;">Status</th>
                                       <th style="color:blue; text-align:center;">Gr&ouml;&szlig;e</th>
                                       <th style="color:blue; text-align:center;">Aktion</th>
                                    <tr>
                                 </thead>
                                 <tbody>
                                 </tbody>
                              </table>
                           </div>
                           <p align='center'>
                              {if $create_edit != ''}
                              <input type="hidden" id="fid" value="{$create_edit}">
                              {else}
                              <input type="hidden" id="fid" value="-1">
                              {/if}
                              <button class="col-6 btn btn-primary btn-sm mt-3" id="save">Speichern</button>
                           </p>
                        </div>
                     </div>
               </div>
               <div id="msg"></div>
               </form>
               <br>
               <div class="card">
                  <div class="card-header">
                     <i class="fas fa-table me-1"></i>
                     Kontostand: {if $kontostand < 0}<font color="red">{/if}<b>{$kontostand}</b>{if $kontostand < 0}</font>{/if}
                     <div class="d-lg-none">
                        <font color="red">Querformat für Mobilgeräte</font>
                     </div>
                  </div>
                  <div class="card-body">
                     <!-- https://datatables.net/download/release -->
                     <table id="myTable" class="table table-striped table-bordered table-hover" >
                        <thead>
                           <tr>
                              <th>Datum</th>
                              <th>Beschreibung</th>
                              <th class="d-none d-lg-table-cell">Firma</th>
                              <th>Beleg</th>
                              <th>Betrag</th>
                              <th>Bemerkung</th>
                              <th>Aktion</th>
                           </tr>
                        </thead>
                        <tbody>
                           {section name=table_data loop=$table_data}
                           <tr>
                              <td>{$table_data[table_data].datum_form}</td>
                              <td>{$table_data[table_data].beschreibung}</td>
                              <td class="d-none d-lg-table-cell">{$table_data[table_data].firma}</td>
                              <td>
                                 {section name=inner loop=$table_data[table_data].inner}
                                 {if $table_data[table_data].inner[inner].file_exists == 1}
                                   <a href="{$table_data[table_data].inner[inner].filename}" target="_new">
                                   <div class="d-sm-block d-lg-none mt-0 mb-0">{$table_data[table_data].inner[inner].originalname_short}</div>
                                   <div class="d-none d-lg-block mt-0 mb-0">{$table_data[table_data].inner[inner].originalname}</div>
                                   </a>
                                 {else}
                                   <div class="d-sm-block d-lg-none mt-0 mb-0">{$table_data[table_data].inner[inner].originalname_short}</div>
                                   <div class="d-none d-lg-block mt-0 mb-0">{$table_data[table_data].inner[inner].originalname}</div>
                                 {/if}
                                 {/section}
                              </td>
                              <td align="right">{$table_data[table_data].betrag_form}</td>
                              <td>{$table_data[table_data].bemerkung}</td>
                              <td>
                                 <a href="?editfid={$table_data[table_data].fid}" class="settings" title="Edit Beleg" data-toggle="tooltip"><i class="fas fa fa-edit"></i></a>
                                 &nbsp;
                                 <a class="btn btn-danger  btn-rounded btn-icon btn-sm" onclick="delBeleg({$table_data[table_data].fid})"><i class="fa fa-trash" style="width:18px;"></i></a>
                              </td>
                           </tr>
                           {/section}
                        </tbody>
                     </table>
                  </div>
               </div>
               </center>
            </main>
            <!-- Livesearchscript muss nach den Textfelder sitzen-->
            <script src="../js/components/admin_notenupload.js"></script>
            <!-- footer -->
            <div id="footer"></div>
         </div>
      </div>
   </body>
   <script>
      $(document).ready(function(){
      var table = new DataTable('#myTable', {
          rowReorder: true,
          pageLength: 5,
                "order": [],
                "fnCreatedRow": function( nRow, aData, iDataIndex ) {
                   var dateFull = aData.date;
                   var dateFullItems = dateFull.split(' ');
                   var dateDatum = dateFullItems[0];
                   var dateDatumItems = dateDatum.split('.');
                  var dateTime = dateFullItems[1];
                  var dateFormat = dateDatumItems[2] + '-' + dateDatumItems[1] + '-' + dateDatumItems[0] + 'T' + dateTime + ':00Z';

                  $(nRow).find('td:nth-of-type(2)').attr('data-sort', dateFormat);
            },
          language: {
              url: '//cdn.datatables.net/plug-ins/1.13.4/i18n/de-DE.json',
           search: "",
       lengthMenu:     "_MENU_ Zeilen",
          },
      });
      });
   </script>
</html>
{/if}