Сравнение значения php с текущей датой и скрытие содержимого - PullRequest
0 голосов
/ 14 сентября 2018

я создаю функцию фильтра, которая сравнивает даты из базы данных с текущей датой и скрывает содержимое, если оно истинно. до сих пор не полностью работает.

вот код:

 <li>
    <input type="checkbox" class="inputnew" id="filter-new" />
    <label for="filter-new">Wiedervorlagetermin</label>
</li>

<?php while($dsk=$stmk->fetch(PDO::FETCH_ASSOC)) : ?>

   <tr>
       <form method="post" action="kontakte.php">
     <td style="font-size:14px;">
        <p><?= htmlspecialchars($dsk['timestamp']); ?></p>
        <input name="anrufe" type="date" value="<?= htmlspecialchars($dsk['timestamp']); ?>" style="display:none; padding: 0;">
     </td>
     <td style="font-size:14px;">
        <p class="label-input"><?= htmlspecialchars($dsk['Anrufe']); ?></p>
        <input name="anrufe" class="edit-input" type="number" value="<?= htmlspecialchars($dsk['Anrufe']); ?>" style="display:none; padding: 0;">
     </td>
     <td style="font-size:14px;">
         <p class="label-input"><?= htmlspecialchars($dsk['Art']); ?></p>
         <input name="art" class="edit-input" value="<?= htmlspecialchars($dsk['Art']); ?>" style="display:none; padding: 0;">
     </td>
     <td style="font-size:14px;">
       <p class="label-input"><?= htmlspecialchars($dsk['Name']); ?></p>
       <input name="name" class="edit-input" value="<?= htmlspecialchars($dsk['Name']); ?>" style="display:none; padding: 0;">
     </td>
     <td style="font-size:14px;">
       <p class="label-input"><?= htmlspecialchars($dsk['Vorname']); ?></p>
       <input name="vorname" class="edit-input" value="<?= htmlspecialchars($dsk['Vorname']); ?>" style="display:none; padding: 0;">
     </td>
     <td style="font-size:14px;">
       <p class="label-input"><?= htmlspecialchars($dsk['Geburtsdatum']); ?></p>
       <input name="geburtsdatum" class="edit-input" type="date" value="<?= htmlspecialchars($dsk['Geburtsdatum']); ?>" style="display:none; padding: 0;">
     </td>
     <td style="font-size:14px;">
       <p class="label-input"><?= htmlspecialchars($dsk['Beruf']); ?></p>
       <input name="beruf" class="edit-input" value="<?= htmlspecialchars($dsk['Beruf']); ?>" style="display:none; padding: 0;">
     </td>

     <td style="font-size:14px;">
       <p class="label-input"><?= htmlspecialchars($dsk['Info']); ?></p>
       <input name="info" class="edit-input" value="<?= htmlspecialchars($dsk['Info']); ?>" style="display:none; padding: 0;">
     </td> 
    <td style="font-size:14px;">
       <p class="label-input"><?= htmlspecialchars($dsk['Telefon']); ?></p>
       <input name="telefon" class="edit-input" type="tel" value="<?= htmlspecialchars($dsk['Telefon']); ?>" style="display:none; padding: 0;">
     </td>
    <td style="font-size:14px;">
       <p class="label-input"><?= htmlspecialchars($dsk['Termin']); ?></p>
       <input name="termin" class="edit-input" type="date" value="<?= htmlspecialchars($dsk['Termin']); ?>" style="display:none" id="vorlageid">
     </td>
    <td>
        <input name="prio" class="outprio" type="checkbox" <?= $dsk['Sofortkunde'] ? "checked": ""; ?>>
     </td>
     <td>
         <button  class="btn btn-danger" name="update" value="speichern" style="padding: 0;" type="submit">Speichern</button>
     </td>
         <input name="hidden" value="<?= htmlspecialchars($dsk['ID']); ?>" type="hidden">

</form>

это таблица, созданная базой данных. второй последний столбец содержит дату, которую я хочу сравнить.

и теперь jquery:

$(function(){
$(document).on('change', '.inputnew', function(){


  if($('.inputnew').prop('checked')) {  

    var vorlage = "<?= ($dsk['Termin']); ?>";

    $.each( vorlage, function() { 
      if(vorlage != date.getdate()) {
        $('.outprio:checked').parent().parent().hide();
      }
      else {

      }
    });

    $('.outprio:not(:checked)').parent().parent().hide();  

  }
  else {
    $('.outprio').parent().parent().show(); 
  }
});
});

часть со скрытыми флажками работает, но все равно показывает неправильные даты. я думаю, что проблема в моей переменной var vorlage, если я проверю ее в консоли браузера, я получу следующее сообщение:

console.log(vorlage);

VM5901: 1 Uncaught ReferenceError: vorlage не определен в: 1: 13

но это тоже не сработало. есть идеи? я на правильном пути или проблема в чем-то другом?

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...