dolibarr 21.0.0-beta
build_withdrawal_file.php
Go to the documentation of this file.
1#!/usr/bin/env php
2<?php
3/* Copyright (C) 2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
4 * Copyright (C) 2005-2010 Laurent Destailleur <eldy@users.sourceforge.net>
5 * Copyright (C) 2024 Frédéric France <frederic.france@free.fr>
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
27if (!defined('NOSESSION')) {
28 define('NOSESSION', '1');
29}
30
31$sapi_type = php_sapi_name();
32$script_file = basename(__FILE__);
33$path = __DIR__.'/';
34
35// Test if batch mode
36if (substr($sapi_type, 0, 3) == 'cgi') {
37 echo "Error: You are using PHP for CGI. To execute ".$script_file." from command line, you must use PHP for CLI mode.\n";
38 exit(1);
39}
40
41require_once $path."../../htdocs/master.inc.php";
42require_once DOL_DOCUMENT_ROOT.'/core/lib/functionscli.lib.php';
43require_once DOL_DOCUMENT_ROOT."/compta/prelevement/class/bonprelevement.class.php";
44require_once DOL_DOCUMENT_ROOT."/compta/facture/class/facture.class.php";
45require_once DOL_DOCUMENT_ROOT."/societe/class/societe.class.php";
46require_once DOL_DOCUMENT_ROOT."/compta/paiement/class/paiement.class.php";
52// Global variables
53$version = constant('DOL_VERSION');
54$error = 0;
55
56$hookmanager->initHooks(array('cli'));
57
58
59/*
60 * Main
61 */
62
63@set_time_limit(0);
64print "***** ".$script_file." (".$version.") pid=".dol_getmypid()." *****\n";
65dol_syslog($script_file." launched with arg ".join(',', $argv));
66
67$datetimeprev = dol_now();
68
69$month = dol_print_date($datetimeprev, "%m");
70$year = dol_print_date($datetimeprev, "%Y");
71
72$user = new User($db);
73$user->fetch(getDolGlobalString('PRELEVEMENT_USER'));
74
75if (!isset($argv[1])) { // Check parameters
76 print "This script check invoices with a withdrawal request and\n";
77 print "then create payment and build a withdraw file.\n";
78 print "Usage: ".$script_file." simu|real\n";
79 exit(1);
80}
81
82$withdrawreceipt = new BonPrelevement($db);
83$result = $withdrawreceipt->create(getDolGlobalString('PRELEVEMENT_CODE_BANQUE'), getDolGlobalString('PRELEVEMENT_CODE_GUICHET'), $argv[1]);
84
85$db->close();
86
87exit(0);
Class to manage withdrawal receipts.
Class to manage Dolibarr users.
dol_getmypid()
Return getmypid() or random PID when function is disabled Some web hosts disable this php function fo...
dol_now($mode='auto')
Return date for now.
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs=null, $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.