dolibarr 23.0.3
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/functions.lib.php';
27require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
28
29
34{
38 public $db;
39
43 public $error = '';
44
48 public $errors = array();
49
53 public $name;
54
58 public $desc;
59
63 public $resprint;
64
68 public $active = "NOT_SET";
69
70
76 public function __construct($db)
77 {
78 $this->db = $db;
79 }
80
88 public static function listDrivers($db, $maxfilenamelength = 0)
89 {
90 global $conf;
91
92 $type = 'printing';
93 $list = array();
94
95 $listoffiles = array();
96 if (!empty($conf->modules_parts['printing'])) {
97 $dirmodels = array_merge(array('/core/modules/printing/'), (array) $conf->modules_parts['printing']);
98 } else {
99 $dirmodels = array('/core/modules/printing/');
100 }
101 foreach ($dirmodels as $dir) {
102 $tmpfiles = dol_dir_list(dol_buildpath($dir, 0), 'all', 0, '\.modules.php', '', 'name', SORT_ASC, 0);
103 if (!empty($tmpfiles)) {
104 $listoffiles = array_merge($listoffiles, $tmpfiles);
105 }
106 }
107 foreach ($listoffiles as $record) {
108 $list[$record['fullname']] = str_replace('.modules.php', '', $record['name']);
109 }
110 return $list;
111 }
112
118 public function getDesc()
119 {
120 global $langs;
121 $langs->load("printing");
122 $transstring = "PrintingModuleDesc".$this->name;
123 if ($langs->trans($transstring) != $transstring) {
124 return $langs->trans($transstring);
125 } else {
126 return $this->desc;
127 }
128 }
129
135 public function listAvailablePrinters()
136 {
137 $msg = get_class($this)."::".__FUNCTION__." not implemented";
138 dol_syslog($msg, LOG_ERR);
139 $this->errors[] = $msg;
140 return 1;
141 }
142
148 public function getlistAvailablePrinters()
149 {
150 $msg = get_class($this)."::".__FUNCTION__." not implemented";
151 dol_syslog($msg, LOG_ERR);
152 $this->errors[] = $msg;
153 return [];
154 }
155
164 public function printFile($file, $module, $subdir = '')
165 {
166 $msg = get_class($this)."::".__FUNCTION__." not implemented";
167 dol_syslog($msg, LOG_ERR);
168 $this->errors[] = $msg;
169 return 1;
170 }
171
179 public function listJobs($module = null)
180 {
181 $msg = get_class($this)."::".__FUNCTION__." not implemented";
182 dol_syslog($msg, LOG_ERR);
183 $this->errors[] = $msg;
184 return 1;
185 }
186}
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.
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:64
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.