dolibarr 20.0.2
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 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 3 of the License, or
11 * (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program. If not, see <https://www.gnu.org/licenses/>.
20 * or see https://www.gnu.org/
21 */
22
29require_once DOL_DOCUMENT_ROOT.'/core/class/commondocgenerator.class.php';
30require_once DOL_DOCUMENT_ROOT.'/core/class/commonnumrefgenerator.class.php';
31require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php';
32require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; // Requis car utilise dans les classes qui heritent
33
38{
39 // No overload code
40}
41
46{
50 public $error = '';
51
52 // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
60 public static function liste_modeles($db, $maxfilenamelength = 0)
61 {
62 // phpcs:enable
63 $type = 'chequereceipt';
64 $list = array();
65
66 include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
67 $list = getListOfModels($db, $type, $maxfilenamelength);
68 // TODO Remove this to use getListOfModels only
69 $list = array('blochet'=>'blochet');
70
71 return $list;
72 }
73}
74
75
87function chequereceipt_pdf_create($db, $id, $message, $modele, $outputlangs)
88{
89 global $conf, $langs;
90 $langs->load("bills");
91
92 $dir = DOL_DOCUMENT_ROOT."/core/modules/cheque/doc/";
93
94 // Positionne modele sur le nom du modele a utiliser
95 if (!dol_strlen($modele)) {
96 if (getDolGlobalString('CHEQUERECEIPT_ADDON_PDF')) {
97 $modele = getDolGlobalString('CHEQUERECEIPT_ADDON_PDF');
98 } else {
99 //print $langs->trans("Error")." ".$langs->trans("Error_FACTURE_ADDON_PDF_NotDefined");
100 //return 0;
101 $modele = 'blochet';
102 }
103 }
104
105 // Charge le modele
106 $file = "pdf_".$modele.".modules.php";
107 if (file_exists($dir.$file)) {
108 $classname = "pdf_".$modele;
109 require_once $dir.$file;
110
111 $obj = new $classname($db);
112
113 // We save charset_output to restore it because write_file can change it if needed for
114 // output format that does not support UTF8.
115 $sav_charset_output = $outputlangs->charset_output;
116 if ($obj->write_file($id, $outputlangs) > 0) {
117 $outputlangs->charset_output = $sav_charset_output;
118 return 1;
119 } else {
120 $outputlangs->charset_output = $sav_charset_output;
121 dol_print_error($db, "chequereceipt_pdf_create Error: ".$obj->error);
122 return -1;
123 }
124 } else {
125 dol_print_error(null, $langs->trans("Error")." ".$langs->trans("ErrorFileDoesNotExists", $dir.$file));
126 return -1;
127 }
128}
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.
Class parent for cheque Receipts numbering references mother class.
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 dolibarr global constant string value.
chequereceipt_pdf_create($db, $id, $message, $modele, $outputlangs)
Cree un bordereau remise de cheque.