dolibarr  13.0.2
build_withdrawal_file.php
Go to the documentation of this file.
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 <https://www.gnu.org/licenses/>.
19  */
20 
27 if (!defined('NOSESSION')) define('NOSESSION', '1');
28 
29 $sapi_type = php_sapi_name();
30 $script_file = basename(__FILE__);
31 $path = __DIR__.'/';
32 
33 // Test if batch mode
34 if (substr($sapi_type, 0, 3) == 'cgi') {
35  echo "Error: You are using PHP for CGI. To execute ".$script_file." from command line, you must use PHP for CLI mode.\n";
36  exit(-1);
37 }
38 
39 require_once $path."../../htdocs/master.inc.php";
40 require_once DOL_DOCUMENT_ROOT."/compta/prelevement/class/bonprelevement.class.php";
41 require_once DOL_DOCUMENT_ROOT."/compta/facture/class/facture.class.php";
42 require_once DOL_DOCUMENT_ROOT."/societe/class/societe.class.php";
43 require_once DOL_DOCUMENT_ROOT."/compta/paiement/class/paiement.class.php";
44 
45 // Global variables
46 $version = constant('DOL_VERSION');
47 $error = 0;
48 
49 /*
50  * Main
51  */
52 
53 @set_time_limit(0);
54 print "***** ".$script_file." (".$version.") pid=".dol_getmypid()." *****\n";
55 dol_syslog($script_file." launched with arg ".join(',', $argv));
56 
57 $datetimeprev = dol_now();
58 
59 $month = strftime("%m", $datetimeprev);
60 $year = strftime("%Y", $datetimeprev);
61 
62 $user = new user($db);
63 $user->fetch($conf->global->PRELEVEMENT_USER);
64 
65 if (!isset($argv[1])) { // Check parameters
66  print "This script check invoices with a withdrawal request and\n";
67  print "then create payment and build a withdraw file.\n";
68  print "Usage: ".$script_file." simu|real\n";
69  exit(-1);
70 }
71 
72 $withdrawreceipt = new BonPrelevement($db);
73 // $conf->global->PRELEVEMENT_CODE_BANQUE and $conf->global->PRELEVEMENT_CODE_GUICHET should be empty
74 $result = $withdrawreceipt->create($conf->global->PRELEVEMENT_CODE_BANQUE, $conf->global->PRELEVEMENT_CODE_GUICHET, $argv[1]);
75 
76 $db->close();
77 
78 exit(0);
dol_now($mode= 'auto')
Return date for now.
dol_getmypid()
Return getmypid() or random PID when function is disabled Some web hosts disable this php function fo...
$conf db user
Definition: repair.php:109
Class to manage withdrawal receipts.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename= '', $restricttologhandler= '', $logcontext=null)
Write log message into outputs.
print
Draft customers invoices.
Definition: index.php:89