build_withdrawal_file.php 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. #!/usr/bin/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=".getmypid()." *****\n";
  46. $datetimeprev = time();
  47. $month = strftime("%m", $datetimeprev);
  48. $year = strftime("%Y", $datetimeprev);
  49. $user = new user($db);
  50. $user->fetch($conf->global->PRELEVEMENT_USER);
  51. print "***** ".$script_file." (".$version.") *****\n";
  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. $result=$withdrawreceipt->create($conf->global->PRELEVEMENT_CODE_BANQUE,$conf->global->PRELEVEMENT_CODE_GUICHET,$argv[1]);
  60. $db->close();
  61. exit(0);
  62. ?>