helpers.php 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  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. $vat = 0;
  17. //if (env('VAT_MANAGE', 0) == 1)
  18. //{
  19. $vats = \App\Models\Vat::select('id', 'name', 'value')->orderBy('value')->get();
  20. if ($i > 0)
  21. {
  22. $iv = 0;
  23. foreach($vats as $vv)
  24. {
  25. if ($vv->id == $i)
  26. {
  27. $iv = $vv->value;
  28. break;
  29. }
  30. }
  31. if ($iv > 0)
  32. $vat = $v / 100 * $iv;
  33. }
  34. //}
  35. return $vat;
  36. }
  37. function mysqlToDate($dt)
  38. {
  39. list($date, $hour) = explode(" ", $dt);
  40. list($year, $month, $day) = explode("-", $date);
  41. return $day . "/" . $month . "/" . $year;
  42. }