dolibarr 25.0.0-alpha
modules_printing.php
Go to the documentation of this file.
1<?php
2/*
3 * Copyright (C) 2014-2025 Frédéric France <frederic.france@free.fr>
4 * Copyright (C) 2024-2025 MDW <mdeweerd@users.noreply.github.com>
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 3 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <https://www.gnu.org/licenses/>.
18 * or see https://www.gnu.org/
19 */
20
26require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
27
28
33{
37 public $db;
38
42 public $error = '';
43
47 public $errors = array();
48
52 public $name;
53
57 public $desc;
58
62 public $resprint;
63
67 public $active = "NOT_SET";
68
69
75 public function __construct($db)
76 {
77 $this->db = $db;
78 }
79
87 public static function listDrivers($db, $maxfilenamelength = 0)
88 {
89 global $conf;
90
91 $type = 'printing';
92 $list = array();
93
94 $listoffiles = array();
95 if (!empty($conf->modules_parts['printing'])) {
96 $dirmodels = array_merge(array('/core/modules/printing/'), (array) $conf->modules_parts['printing']);
97 } else {
98 $dirmodels = array('/core/modules/printing/');
99 }
100 foreach ($dirmodels as $dir) {
101 $tmpfiles = dol_dir_list(dol_buildpath($dir, 0), 'all', 0, '\.modules.php', '', 'name', SORT_ASC, 0);
102 if (!empty($tmpfiles)) {
103 $listoffiles = array_merge($listoffiles, $tmpfiles);
104 }
105 }
106 foreach ($listoffiles as $record) {
107 $list[$record['fullname']] = str_replace('.modules.php', '', $record['name']);
108 }
109 return $list;
110 }
111
117 public function getDesc()
118 {
119 global $langs;
120 $langs->load("printing");
121 $transstring = "PrintingModuleDesc".$this->name;
122 if ($langs->trans($transstring) != $transstring) {
123 return $langs->trans($transstring);
124 } else {
125 return $this->desc;
126 }
127 }
128
134 public function listAvailablePrinters()
135 {
136 $msg = get_class($this)."::".__FUNCTION__." not implemented";
137 dol_syslog($msg, LOG_ERR);
138 $this->errors[] = $msg;
139 return 1;
140 }
141
147 public function getlistAvailablePrinters()
148 {
149 $msg = get_class($this)."::".__FUNCTION__." not implemented";
150 dol_syslog($msg, LOG_ERR);
151 $this->errors[] = $msg;
152 return [];
153 }
154
163 public function printFile($file, $module, $subdir = '')
164 {
165 $msg = get_class($this)."::".__FUNCTION__." not implemented";
166 dol_syslog($msg, LOG_ERR);
167 $this->errors[] = $msg;
168 return 1;
169 }
170
178 public function listJobs($module = null)
179 {
180 $msg = get_class($this)."::".__FUNCTION__." not implemented";
181 dol_syslog($msg, LOG_ERR);
182 $this->errors[] = $msg;
183 return 1;
184 }
185}
Parent class of emailing target selectors modules.
listJobs($module=null)
List jobs print.
listAvailablePrinters()
Return list of available printers.
printFile($file, $module, $subdir='')
Print selected file.
static listDrivers($db, $maxfilenamelength=0)
Return list of printing driver.
__construct($db)
Constructor.
getDesc()
Return description of Printing Module.
getlistAvailablePrinters()
Return list of available printers.
if(!isModEnabled('ai')||!getDolGlobalString('AI_ASSISTANT_ENABLED')) global $conf
The main.inc.php has been included so the following variable are now defined:
dol_dir_list($utf8_path, $types="all", $recursive=0, $filter="", $excludefilter=null, $sortcriteria="name", $sortorder=SORT_ASC, $mode=0, $nohook=0, $relativename="", $donotfollowsymlinks=0, $nbsecondsold=0)
Scan a directory and return a list of files/directories.
Definition files.lib.php:65
dol_buildpath($path, $type=0, $returnemptyifnotfound=0)
Return path of url or filesystem.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.