dolibarr 21.0.0-beta
modules_chequereceipts.php
Go to the documentation of this file.
1<?php
2/* Copyright (C) 2003-2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
3 * Copyright (C) 2004-2009 Laurent Destailleur <eldy@users.sourceforge.net>
4 * Copyright (C) 2004 Eric Seigne <eric.seigne@ryxeo.com>
5 * Copyright (C) 2005-2009 Regis Houssin <regis.houssin@inodbox.com>
6 * Copyright (C) 2016 Juanjo Menent <jmenent@2byte.es>
7 * Copyright (C) 2024 MDW <mdeweerd@users.noreply.github.com>
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 3 of the License, or
12 * (at your option) any later version.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program. If not, see <https://www.gnu.org/licenses/>.
21 * or see https://www.gnu.org/
22 */
23
30require_once DOL_DOCUMENT_ROOT.'/core/class/commondocgenerator.class.php';
31require_once DOL_DOCUMENT_ROOT.'/core/class/commonnumrefgenerator.class.php';
32require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php';
33require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; // Requis car utilise dans les classes qui heritent
34
39{
40 // No overload code
48 abstract public function getNextValue($objsoc, $object);
49
55 abstract public function getExample();
56}
57
62{
66 public $account;
67
71 public $amount;
75 public $date;
79 public $nbcheque;
83 public $ref;
87 public $lines;
91 public $error = '';
92
93 // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
101 public static function liste_modeles($db, $maxfilenamelength = 0)
102 {
103 // phpcs:enable
104 $type = 'chequereceipt';
105 $list = array();
106
107 include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
108 $list = getListOfModels($db, $type, $maxfilenamelength);
109 // TODO Remove this to use getListOfModels only
110 $list = array('blochet' => 'blochet');
111
112 return $list;
113 }
114
115
116 // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
126 abstract public function write_file($object, $_dir, $number, $outputlangs);
127 // phpcs:enable
128}
129
130
142function chequereceipt_pdf_create($db, $id, $message, $modele, $outputlangs)
143{
144 global $conf, $langs;
145 $langs->load("bills");
146
147 $dir = DOL_DOCUMENT_ROOT."/core/modules/cheque/doc/";
148
149 // Positionne modele sur le nom du modele a utiliser
150 if (!dol_strlen($modele)) {
151 if (getDolGlobalString('CHEQUERECEIPT_ADDON_PDF')) {
152 $modele = getDolGlobalString('CHEQUERECEIPT_ADDON_PDF');
153 } else {
154 //print $langs->trans("Error")." ".$langs->trans("Error_FACTURE_ADDON_PDF_NotDefined");
155 //return 0;
156 $modele = 'blochet';
157 }
158 }
159
160 // Charge le modele
161 $file = "pdf_".$modele.".modules.php";
162 if (file_exists($dir.$file)) {
163 $classname = "pdf_".$modele;
164 require_once $dir.$file;
165
166 $obj = new $classname($db);
167 '@phan-var-force ModeleChequeReceipts $obj';
168
169 // We save charset_output to restore it because write_file can change it if needed for
170 // output format that does not support UTF8.
171 $sav_charset_output = $outputlangs->charset_output;
172 // TODO: write_file seems invalid, function is likely no longer used - delete ?
173 if ($obj->write_file($id, $outputlangs) > 0) { // @phan-suppress-current-line PhanParamTooFew,PhanPluginSuspiciousParamPosition
174 $outputlangs->charset_output = $sav_charset_output;
175 return 1;
176 } else {
177 $outputlangs->charset_output = $sav_charset_output;
178 dol_print_error($db, "chequereceipt_pdf_create Error: ".$obj->error);
179 return -1;
180 }
181 } else {
182 dol_print_error(null, $langs->trans("Error")." ".$langs->trans("ErrorFileDoesNotExists", $dir.$file));
183 return -1;
184 }
185}
$id
Definition account.php:48
if( $user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $object
Definition card.php:66
Parent class for documents (PDF, ODT, ...) generators.
Parent class for number ref generators.
Class parent for templates of document generation.
static liste_modeles($db, $maxfilenamelength=0)
Return list of active generation modules.
write_file($object, $_dir, $number, $outputlangs)
Fonction to generate document on disk.
Class parent for cheque Receipts numbering references mother class.
getExample()
Return an example of numbering.
getNextValue($objsoc, $object)
Return next free value.
getListOfModels($db, $type, $maxfilenamelength=0)
Return list of activated modules usable for document generation.
dol_strlen($string, $stringencoding='UTF-8')
Make a strlen call.
dol_print_error($db=null, $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
global $conf
The following vars must be defined: $type2label $form $conf, $lang, The following vars may also be de...
Definition member.php:79
chequereceipt_pdf_create($db, $id, $message, $modele, $outputlangs)
Cree un bordereau remise de cheque.