dolibarr 22.0.5
modules_printing.php
Go to the documentation of this file.
1<?php
2/*
3 * Copyright (C) 2014-2024 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
50
54 public $name;
55
59 public $desc;
60
64 public $resprint;
65
69 public $active = "NOT_SET";
70
71
77 public function __construct($db)
78 {
79 $this->db = $db;
80 }
81
89 public static function listDrivers($db, $maxfilenamelength = 0)
90 {
91 global $conf;
92
93 $type = 'printing';
94 $list = array();
95
96 $listoffiles = array();
97 if (!empty($conf->modules_parts['printing'])) {
98 $dirmodels = array_merge(array('/core/modules/printing/'), (array) $conf->modules_parts['printing']);
99 } else {
100 $dirmodels = array('/core/modules/printing/');
101 }
102 foreach ($dirmodels as $dir) {
103 $tmpfiles = dol_dir_list(dol_buildpath($dir, 0), 'all', 0, '\.modules.php', '', 'name', SORT_ASC, 0);
104 if (!empty($tmpfiles)) {
105 $listoffiles = array_merge($listoffiles, $tmpfiles);
106 }
107 }
108 foreach ($listoffiles as $record) {
109 $list[$record['fullname']] = str_replace('.modules.php', '', $record['name']);
110 }
111 return $list;
112 }
113
119 public function getDesc()
120 {
121 global $langs;
122 $langs->load("printing");
123 $transstring = "PrintingModuleDesc".$this->name;
124 if ($langs->trans($transstring) != $transstring) {
125 return $langs->trans($transstring);
126 } else {
127 return $this->desc;
128 }
129 }
130
136 public function listAvailablePrinters()
137 {
138 $msg = get_class($this)."::".__FUNCTION__." not implemented";
139 dol_syslog($msg, LOG_ERR);
140 $this->errors[] = $msg;
141 return 1;
142 }
143
149 public function getlistAvailablePrinters()
150 {
151 $msg = get_class($this)."::".__FUNCTION__." not implemented";
152 dol_syslog($msg, LOG_ERR);
153 $this->errors[] = $msg;
154 return [];
155 }
156
165 public function printFile($file, $module, $subdir = '')
166 {
167 $msg = get_class($this)."::".__FUNCTION__." not implemented";
168 dol_syslog($msg, LOG_ERR);
169 $this->errors[] = $msg;
170 return 1;
171 }
172
180 public function listJobs($module = null)
181 {
182 $msg = get_class($this)."::".__FUNCTION__." not implemented";
183 dol_syslog($msg, LOG_ERR);
184 $this->errors[] = $msg;
185 return 1;
186 }
187}
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:63
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.
global $conf
The following vars must be defined: $type2label $form $conf, $lang, The following vars may also be de...
Definition member.php:79