eventAdd.php 2.1 KB

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