helpers.php 926 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. <?php
  2. function getCards()
  3. {
  4. return \App\Models\Card::where('enabled', true)->orderBy('name')->get();
  5. }
  6. function getCategories()
  7. {
  8. return \App\Models\Category::where('enabled', true)->where('parent_id', null)->orderBy('name')->get();
  9. }
  10. function formatPrice($price)
  11. {
  12. return "€ " . number_format($price, 2, ",", ".");
  13. }
  14. function getVatValue($v, $i)
  15. {
  16. $vats = \App\Models\Vat::select('id', 'name', 'value')->orderBy('value')->get();
  17. $vat = 0;
  18. if ($i > 0)
  19. {
  20. $iv = 0;
  21. foreach($vats as $vv)
  22. {
  23. if ($vv->id == $i)
  24. {
  25. $iv = $vv->value;
  26. break;
  27. }
  28. }
  29. if ($iv > 0)
  30. $vat = $v / 100 * $iv;
  31. }
  32. return $vat;
  33. }
  34. function mysqlToDate($dt)
  35. {
  36. list($date, $hour) = explode(" ", $dt);
  37. list($year, $month, $day) = explode("-", $date);
  38. return $day . "/" . $month . "/" . $year;
  39. }