dolibarr 21.0.0-beta
modules_fichinter.php
Go to the documentation of this file.
1<?php
2/* Copyright (C) 2003 Rodolphe Quiedeville <rodolphe@quiedeville.org>
3 * Copyright (C) 2004-2011 Laurent Destailleur <eldy@users.sourceforge.net>
4 * Copyright (C) 2005-2012 Regis Houssin <regis.houssin@inodbox.com>
5 * Copyright (C) 2011-2019 Philippe Grand <philippe.grand@atoo-net.com>
6 * Copyright (C) 2024 MDW <mdeweerd@users.noreply.github.com>
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
30require_once DOL_DOCUMENT_ROOT.'/core/class/commondocgenerator.class.php';
31require_once DOL_DOCUMENT_ROOT.'/core/class/commonnumrefgenerator.class.php';
32
33
38{
39 // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
47 public static function liste_modeles($db, $maxfilenamelength = 0)
48 {
49 // phpcs:enable
50 $type = 'ficheinter';
51 $list = array();
52
53 include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
54 $list = getListOfModels($db, $type, $maxfilenamelength);
55
56 return $list;
57 }
58
59
60 // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
72 abstract public function write_file($object, $outputlangs, $srctemplatepath = '', $hidedetails = 0, $hidedesc = 0, $hideref = 0);
73}
74
75
80{
88 abstract public function getNextValue($objsoc = '', $object = '');
89
95 abstract public function getExample();
96}
97
98
99// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
112function fichinter_create($db, $object, $modele, $outputlangs, $hidedetails = 0, $hidedesc = 0, $hideref = 0)
113{
114 // phpcs:enable
115 global $conf, $langs;
116 $langs->load("ficheinter");
117
118 $error = 0;
119
120 $srctemplatepath = '';
121
122 // Positionne modele sur le nom du modele de fichinter a utiliser
123 if (!dol_strlen($modele)) {
124 if (getDolGlobalString('FICHEINTER_ADDON_PDF')) {
125 $modele = getDolGlobalString('FICHEINTER_ADDON_PDF');
126 } else {
127 $modele = 'soleil';
128 }
129 }
130
131 // If selected modele is a filename template (then $modele="modelname:filename")
132 $tmp = explode(':', $modele, 2);
133 if (!empty($tmp[1])) {
134 $modele = $tmp[0];
135 $srctemplatepath = $tmp[1];
136 }
137
138 // Search template files
139 $file = '';
140 $classname = '';
141 $dirmodels = array('/');
142 if (is_array($conf->modules_parts['models'])) {
143 $dirmodels = array_merge($dirmodels, $conf->modules_parts['models']);
144 }
145 foreach ($dirmodels as $reldir) {
146 foreach (array('doc', 'pdf') as $prefix) {
147 $file = $prefix."_".$modele.".modules.php";
148
149 // Get the location of the module and verify it exists
150 $file = dol_buildpath($reldir."core/modules/fichinter/doc/".$file, 0);
151 if (file_exists($file)) {
152 $classname = $prefix.'_'.$modele;
153 break;
154 }
155 }
156 if ($classname !== '') {
157 break;
158 }
159 }
160
161 // Charge le modele
162 if ($classname !== '') {
163 require_once $file;
164
165 $obj = new $classname($db);
166
167 '@phan-var-force ModelePDFFicheinter $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 if ($obj->write_file($object, $outputlangs, $srctemplatepath, $hidedetails, $hidedesc, $hideref) > 0) {
173 $outputlangs->charset_output = $sav_charset_output;
174
175 // We delete old preview
176 require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
178
179 return 1;
180 } else {
181 $outputlangs->charset_output = $sav_charset_output;
182 dol_print_error($db, "fichinter_pdf_create Error: ".$obj->error);
183 return 0;
184 }
185 } else {
186 print $langs->trans("Error")." ".$langs->trans("ErrorFileDoesNotExists", $file);
187 return 0;
188 }
189}
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.
Parent class numbering models of intervention sheet references.
getNextValue($objsoc='', $object='')
Return next free value.
getExample()
Return an example of numbering.
Parent class to manage intervention document templates.
write_file($object, $outputlangs, $srctemplatepath='', $hidedetails=0, $hidedesc=0, $hideref=0)
Function to build pdf onto disk.
static liste_modeles($db, $maxfilenamelength=0)
Return list of active generation modules.
dol_delete_preview($object)
Delete all preview files linked to object instance.
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_buildpath($path, $type=0, $returnemptyifnotfound=0)
Return path of url or filesystem.
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
fichinter_create($db, $object, $modele, $outputlangs, $hidedetails=0, $hidedesc=0, $hideref=0)
Create an intervention document on disk using template defined into FICHEINTER_ADDON_PDF.