build_withdrawal_file.php 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. #!/usr/bin/env php
  2. <?php
  3. /*
  4. * Copyright (C) 2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
  5. * Copyright (C) 2005-2010 Laurent Destailleur <eldy@users.sourceforge.net>
  6. *
  7. * This program is free software; you can redistribute it and/or modify
  8. * it under the terms of the GNU General Public License as published by
  9. * the Free Software Foundation; either version 3 of the License, or
  10. * (at your option) any later version.
  11. *
  12. * This program is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. * GNU General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU General Public License
  18. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  19. */
  20. /**
  21. * \file scripts/withdrawals/build_withdrawal_file.php
  22. * \ingroup prelevement
  23. * \brief Script de prelevement
  24. */
  25. $sapi_type = php_sapi_name();
  26. $script_file = basename(__FILE__);
  27. $path=dirname(__FILE__).'/';
  28. // Test if batch mode
  29. if (substr($sapi_type, 0, 3) == 'cgi') {
  30. echo "Error: You are using PHP for CGI. To execute ".$script_file." from command line, you must use PHP for CLI mode.\n";
  31. exit(-1);
  32. }
  33. require_once $path."../../htdocs/master.inc.php";
  34. require_once DOL_DOCUMENT_ROOT."/compta/prelevement/class/bonprelevement.class.php";
  35. require_once DOL_DOCUMENT_ROOT."/compta/facture/class/facture.class.php";
  36. require_once DOL_DOCUMENT_ROOT."/societe/class/societe.class.php";
  37. require_once DOL_DOCUMENT_ROOT."/compta/paiement/class/paiement.class.php";
  38. // Global variables
  39. $version=DOL_VERSION;
  40. $error=0;
  41. /*
  42. * Main
  43. */
  44. @set_time_limit(0);
  45. print "***** ".$script_file." (".$version.") pid=".dol_getmypid()." *****\n";
  46. dol_syslog($script_file." launched with arg ".join(',',$argv));
  47. $datetimeprev = dol_now();
  48. $month = strftime("%m", $datetimeprev);
  49. $year = strftime("%Y", $datetimeprev);
  50. $user = new user($db);
  51. $user->fetch($conf->global->PRELEVEMENT_USER);
  52. if (! isset($argv[1])) { // Check parameters
  53. print "This script check invoices with a withdrawal request and\n";
  54. print "then create payment and build a withdraw file.\n";
  55. print "Usage: ".$script_file." simu|real\n";
  56. exit(-1);
  57. }
  58. $withdrawreceipt=new BonPrelevement($db);
  59. // $conf->global->PRELEVEMENT_CODE_BANQUE and $conf->global->PRELEVEMENT_CODE_GUICHET should be empty
  60. $result=$withdrawreceipt->create($conf->global->PRELEVEMENT_CODE_BANQUE,$conf->global->PRELEVEMENT_CODE_GUICHET,$argv[1]);
  61. $db->close();
  62. exit(0);