dolibarr 20.0.0
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
65{
66 // No overload code
67}
68
69
70// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
83function fichinter_create($db, $object, $modele, $outputlangs, $hidedetails = 0, $hidedesc = 0, $hideref = 0)
84{
85 // phpcs:enable
86 global $conf, $langs;
87 $langs->load("ficheinter");
88
89 $error = 0;
90
91 $srctemplatepath = '';
92
93 // Positionne modele sur le nom du modele de fichinter a utiliser
94 if (!dol_strlen($modele)) {
95 if (getDolGlobalString('FICHEINTER_ADDON_PDF')) {
96 $modele = getDolGlobalString('FICHEINTER_ADDON_PDF');
97 } else {
98 $modele = 'soleil';
99 }
100 }
101
102 // If selected modele is a filename template (then $modele="modelname:filename")
103 $tmp = explode(':', $modele, 2);
104 if (!empty($tmp[1])) {
105 $modele = $tmp[0];
106 $srctemplatepath = $tmp[1];
107 }
108
109 // Search template files
110 $file = '';
111 $classname = '';
112 $dirmodels = array('/');
113 if (is_array($conf->modules_parts['models'])) {
114 $dirmodels = array_merge($dirmodels, $conf->modules_parts['models']);
115 }
116 foreach ($dirmodels as $reldir) {
117 foreach (array('doc', 'pdf') as $prefix) {
118 $file = $prefix."_".$modele.".modules.php";
119
120 // Get the location of the module and verify it exists
121 $file = dol_buildpath($reldir."core/modules/fichinter/doc/".$file, 0);
122 if (file_exists($file)) {
123 $classname = $prefix.'_'.$modele;
124 break;
125 }
126 }
127 if ($classname !== '') {
128 break;
129 }
130 }
131
132 // Charge le modele
133 if ($classname !== '') {
134 require_once $file;
135
136 $obj = new $classname($db);
137
138 // We save charset_output to restore it because write_file can change it if needed for
139 // output format that does not support UTF8.
140 $sav_charset_output = $outputlangs->charset_output;
141 if ($obj->write_file($object, $outputlangs, $srctemplatepath, $hidedetails, $hidedesc, $hideref) > 0) {
142 $outputlangs->charset_output = $sav_charset_output;
143
144 // We delete old preview
145 require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
147
148 return 1;
149 } else {
150 $outputlangs->charset_output = $sav_charset_output;
151 dol_print_error($db, "fichinter_pdf_create Error: ".$obj->error);
152 return 0;
153 }
154 } else {
155 print $langs->trans("Error")." ".$langs->trans("ErrorFileDoesNotExists", $file);
156 return 0;
157 }
158}
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.
Parent class numbering models of intervention sheet references.
Parent class to manage intervention document templates.
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 dolibarr global constant string value.
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.