dolibarr  17.0.4
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 
29 require_once DOL_DOCUMENT_ROOT.'/core/class/commondocgenerator.class.php';
30 require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php';
31 require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; // Requis car utilise dans les classes qui heritent
32 
38 {
42  public $error = '';
43 
49  public function isEnabled()
50  {
51  return true;
52  }
53 
59  public function info()
60  {
61  global $langs;
62  $langs->load("bills");
63  return $langs->trans("NoDescription");
64  }
65 
71  public function getExample()
72  {
73  global $langs;
74  $langs->load("bills");
75  return $langs->trans("NoExample");
76  }
77 
84  public function canBeActivated()
85  {
86  return true;
87  }
88 
96  public function getNextValue($objsoc, $object)
97  {
98  global $langs;
99  return $langs->trans("NotAvailable");
100  }
101 
107  public function getVersion()
108  {
109  global $langs;
110  $langs->load("admin");
111 
112  if ($this->version == 'development') {
113  return $langs->trans("VersionDevelopment");
114  }
115  if ($this->version == 'experimental') {
116  return $langs->trans("VersionExperimental");
117  }
118  if ($this->version == 'dolibarr') {
119  return DOL_VERSION;
120  }
121  if ($this->version) {
122  return $this->version;
123  }
124  return $langs->trans("NotAvailable");
125  }
126 }
127 
132 {
136  public $error = '';
137 
138  // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
146  public static function liste_modeles($db, $maxfilenamelength = 0)
147  {
148  // phpcs:enable
149  global $conf;
150 
151  $type = 'chequereceipt';
152  $list = array();
153 
154  include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
155  $list = getListOfModels($db, $type, $maxfilenamelength);
156  // TODO Remove this to use getListOfModels only
157  $list = array('blochet'=>'blochet');
158 
159  return $list;
160  }
161 }
162 
163 
175 function chequereceipt_pdf_create($db, $id, $message, $modele, $outputlangs)
176 {
177  global $conf, $langs;
178  $langs->load("bills");
179 
180  $dir = DOL_DOCUMENT_ROOT."/core/modules/cheque/doc/";
181 
182  // Positionne modele sur le nom du modele a utiliser
183  if (!dol_strlen($modele)) {
184  if (!empty($conf->global->CHEQUERECEIPT_ADDON_PDF)) {
185  $modele = $conf->global->CHEQUERECEIPT_ADDON_PDF;
186  } else {
187  //print $langs->trans("Error")." ".$langs->trans("Error_FACTURE_ADDON_PDF_NotDefined");
188  //return 0;
189  $modele = 'blochet';
190  }
191  }
192 
193  // Charge le modele
194  $file = "pdf_".$modele.".modules.php";
195  if (file_exists($dir.$file)) {
196  $classname = "pdf_".$modele;
197  require_once $dir.$file;
198 
199  $obj = new $classname($db);
200 
201  // We save charset_output to restore it because write_file can change it if needed for
202  // output format that does not support UTF8.
203  $sav_charset_output = $outputlangs->charset_output;
204  if ($obj->write_file($id, $outputlangs) > 0) {
205  $outputlangs->charset_output = $sav_charset_output;
206  return 1;
207  } else {
208  $outputlangs->charset_output = $sav_charset_output;
209  dol_print_error($db, "chequereceipt_pdf_create Error: ".$obj->error);
210  return -1;
211  }
212  } else {
213  dol_print_error('', $langs->trans("Error")." ".$langs->trans("ErrorFileDoesNotExists", $dir.$file));
214  return -1;
215  }
216 }
Parent class for documents generators.
Class parent for templates of document generation.
static liste_modeles($db, $maxfilenamelength=0)
Return list of active generation modules.
Cheque Receipts numbering references mother class.
getExample()
Return numbering example.
canBeActivated()
Checks if the numbers already in the database do not cause conflicts that would prevent this numberin...
getNextValue($objsoc, $object)
Returns the next value.
isEnabled()
Return if a module can be used or not.
getVersion()
Returns the module numbering version.
info()
Return the default description of numbering module.
getListOfModels($db, $type, $maxfilenamelength=0)
Return list of activated modules usable for document generation.
dol_print_error($db='', $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
dol_strlen($string, $stringencoding='UTF-8')
Make a strlen call.
chequereceipt_pdf_create($db, $id, $message, $modele, $outputlangs)
Cree un bordereau remise de cheque.