calcmens.php 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. <?php
  2. /* TVI
  3. * Copyright (C) 2015 Florian HENRY <florian.henry@open-concept.pro>
  4. * Copyright (C) 2020 Maxime DEMAREST <maxime@indelog.fr>
  5. *
  6. * This program is free software; you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License as published by
  8. * the Free Software Foundation; either version 3 of the License, or
  9. * (at your option) any later version.
  10. *
  11. * This program is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License
  17. * along with this program. If not, see <https://www.gnu.org/licenses/>.
  18. */
  19. /**
  20. * \file htdocs/loan/calcmens.php
  21. * \ingroup loan
  22. * \brief File to calculate loan monthly payments
  23. */
  24. if (!defined('NOTOKENRENEWAL')) {
  25. define('NOTOKENRENEWAL', '1'); // Disables token renewal
  26. }
  27. if (!defined('NOREQUIREMENU')) {
  28. define('NOREQUIREMENU', '1');
  29. }
  30. if (!defined('NOREQUIREAJAX')) {
  31. define('NOREQUIREAJAX', '1');
  32. }
  33. require '../main.inc.php';
  34. require DOL_DOCUMENT_ROOT.'/core/lib/loan.lib.php';
  35. $mens = price2num(GETPOST('mens'));
  36. $capital = price2num(GETPOST('capital'));
  37. $rate = price2num(GETPOST('rate'));
  38. $echance = GETPOST('echeance', 'int');
  39. $nbterm = GETPOST('nbterm', 'int');
  40. top_httphead();
  41. $output = array();
  42. $output = loanCalcMonthlyPayment($mens, $capital, $rate, $echance, $nbterm);
  43. echo json_encode($output);