dolibarr  7.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@capnetworks.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 <http://www.gnu.org/licenses/>.
20  * or see http://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 {
39  var $error='';
40 
46  function isEnabled()
47  {
48  return true;
49  }
50 
56  function info()
57  {
58  global $langs;
59  $langs->load("bills");
60  return $langs->trans("NoDescription");
61  }
62 
68  function getExample()
69  {
70  global $langs;
71  $langs->load("bills");
72  return $langs->trans("NoExample");
73  }
74 
80  function canBeActivated()
81  {
82  return true;
83  }
84 
92  function getNextValue($objsoc,$object)
93  {
94  global $langs;
95  return $langs->trans("NotAvailable");
96  }
97 
103  function getVersion()
104  {
105  global $langs;
106  $langs->load("admin");
107 
108  if ($this->version == 'development') return $langs->trans("VersionDevelopment");
109  if ($this->version == 'experimental') return $langs->trans("VersionExperimental");
110  if ($this->version == 'dolibarr') return DOL_VERSION;
111  if ($this->version) return $this->version;
112  return $langs->trans("NotAvailable");
113  }
114 }
115 
121 {
122  var $error='';
123 
131  static function liste_modeles($db,$maxfilenamelength=0)
132  {
133  global $conf;
134 
135  $type='chequereceipt';
136  $liste=array();
137 
138  include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
139  $liste=getListOfModels($db,$type,$maxfilenamelength);
140  // TODO Remove this to use getListOfModels only
141  $liste = array('blochet'=>'blochet');
142 
143  return $liste;
144  }
145 }
146 
147 
159 function chequereceipt_pdf_create($db, $id, $message, $modele, $outputlangs)
160 {
161  global $conf,$langs;
162  $langs->load("bills");
163 
164  $dir = DOL_DOCUMENT_ROOT . "/core/modules/cheque/doc/";
165 
166  // Positionne modele sur le nom du modele a utiliser
167  if (! dol_strlen($modele))
168  {
169  if (! empty($conf->global->CHEQUERECEIPT_ADDON_PDF))
170  {
171  $modele = $conf->global->CHEQUERECEIPT_ADDON_PDF;
172  }
173  else
174  {
175  //print $langs->trans("Error")." ".$langs->trans("Error_FACTURE_ADDON_PDF_NotDefined");
176  //return 0;
177  $modele = 'blochet';
178  }
179  }
180 
181  // Charge le modele
182  $file = "pdf_".$modele.".modules.php";
183  if (file_exists($dir.$file))
184  {
185  $classname = "pdf_".$modele;
186  require_once $dir.$file;
187 
188  $obj = new $classname($db);
189 
190  // We save charset_output to restore it because write_file can change it if needed for
191  // output format that does not support UTF8.
192  $sav_charset_output=$outputlangs->charset_output;
193  if ($obj->write_file($id, $outputlangs) > 0)
194  {
195  $outputlangs->charset_output=$sav_charset_output;
196  return 1;
197  }
198  else
199  {
200  $outputlangs->charset_output=$sav_charset_output;
201  dol_print_error($db,"chequereceipt_pdf_create Error: ".$obj->error);
202  return -1;
203  }
204 
205  }
206  else
207  {
208  dol_print_error('',$langs->trans("Error")." ".$langs->trans("ErrorFileDoesNotExists",$dir.$file));
209  return -1;
210  }
211 }
212 
getVersion()
Returns the module numbering version.
chequereceipt_pdf_create($db, $id, $message, $modele, $outputlangs)
Cree un bordereau remise de cheque.
getNextValue($objsoc, $object)
Returns the next value.
static liste_modeles($db, $maxfilenamelength=0)
Return list of active generation modules.
info()
Return the default description of numbering module.
getExample()
Return numbering example.
dol_print_error($db='', $error='', $errors=null)
Affiche message erreur system avec toutes les informations pour faciliter le diagnostic et la remonte...
Cheque Receipts numbering references mother class.
Classe mere des modeles de.
isEnabled()
Return if a module can be used or not.
canBeActivated()
Test if the existing numbers in the database do not cause conflicts that would prevent this numbering...
Parent class for documents generators.
getListOfModels($db, $type, $maxfilenamelength=0)
Return list of activated modules usable for document generation.
dol_strlen($string, $stringencoding='UTF-8')
Make a strlen call.