eventAdd.php 1.7 KB

12345678910111213141516171819202122232425262728293031323334
  1. <?php
  2. global $account;
  3. Beneficiary::LoadAll();
  4. Context::LoadAll();
  5. ?><!DOCTYPE html5><html><body><form method="post" action="#">
  6. <label><span>label</span><input type="text" name="label" value="<?php echo $template ? $template->getLabel() : ""; ?>"/></label>
  7. <label><span>context</span><select name="context[]" multiple value="<?php echo $template ? Context::Serialize($template->getContext()) : ""; ?>"><?php
  8. $contexts = Context::ListAll();
  9. usort($contexts, function($a, $b) { return strcasecmp($a->getLabel(), $b->getLabel());});
  10. foreach ($contexts as $ctx) {
  11. $selected = "";
  12. if ($template) {
  13. foreach ($template->getContext() as $templateCtx) {
  14. if ($templateCtx->getId() === $ctx->getId()) {
  15. $selected = "selected";
  16. break;
  17. }
  18. }
  19. }
  20. echo '<option value="' .$ctx->getId() .'" ' .$selected .'>' .$ctx->getLabel() ."</option>";
  21. }
  22. ?></select></label>
  23. <label><span>beneficiary</span><select name="beneficiary" value="<?php echo $template ? $template->getBeneficiary()->getId() : ""; ?>"><?php
  24. $beneficiaries = Beneficiary::ListAll();
  25. usort($beneficiaries, function($a, $b) {return strcasecmp($a->getLabel(), $b->getLabel());});
  26. foreach ($beneficiaries as $beneficiary) { ?>
  27. <option value="<?php echo $beneficiary->getId(); ?>"><?php echo $beneficiary->getLabel(); ?></option><?php } ?></select></label>
  28. <label><span>date</span><input type="date" name="paymentDate" value="<?php echo $template ? $template->getPaymentDate()->format("Y-m-d") : ""; ?>"/></label>
  29. <label><span>amount</span><input type="number" name="amount" step="0.01" min="0" value="<?php echo $template ? $template->getAmount() : ""; ?>"/></label>
  30. <input type="submit" value="Add"/>
  31. </form>
  32. </html>