dolibarr 21.0.0-alpha
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 // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
124 abstract public function write_file($object, $_dir, $number, $outputlangs);
125 // phpcs:enable
126}
127
128
140function chequereceipt_pdf_create($db, $id, $message, $modele, $outputlangs)
141{
142 global $conf, $langs;
143 $langs->load("bills");
144
145 $dir = DOL_DOCUMENT_ROOT."/core/modules/cheque/doc/";
146
147 // Positionne modele sur le nom du modele a utiliser
148 if (!dol_strlen($modele)) {
149 if (getDolGlobalString('CHEQUERECEIPT_ADDON_PDF')) {
150 $modele = getDolGlobalString('CHEQUERECEIPT_ADDON_PDF');
151 } else {
152 //print $langs->trans("Error")." ".$langs->trans("Error_FACTURE_ADDON_PDF_NotDefined");
153 //return 0;
154 $modele = 'blochet';
155 }
156 }
157
158 // Charge le modele
159 $file = "pdf_".$modele.".modules.php";
160 if (file_exists($dir.$file)) {
161 $classname = "pdf_".$modele;
162 require_once $dir.$file;
163
164 $obj = new $classname($db);
165 '@phan-var-force ModeleChequeReceipts $obj';
166
167 // We save charset_output to restore it because write_file can change it if needed for
168 // output format that does not support UTF8.
169 $sav_charset_output = $outputlangs->charset_output;
170 if ($obj->write_file($id, $outputlangs) > 0) {
171 $outputlangs->charset_output = $sav_charset_output;
172 return 1;
173 } else {
174 $outputlangs->charset_output = $sav_charset_output;
175 dol_print_error($db, "chequereceipt_pdf_create Error: ".$obj->error);
176 return -1;
177 }
178 } else {
179 dol_print_error(null, $langs->trans("Error")." ".$langs->trans("ErrorFileDoesNotExists", $dir.$file));
180 return -1;
181 }
182}
$id
Definition account.php:39
if( $user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $object
Definition card.php:58
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.
chequereceipt_pdf_create($db, $id, $message, $modele, $outputlangs)
Cree un bordereau remise de cheque.