dolibarr 21.0.0-alpha
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 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
71 public function __construct($db)
72 {
73 $this->db = $db;
74 }
75
83 public static function listDrivers($db, $maxfilenamelength = 0)
84 {
85 global $conf;
86
87 $type = 'printing';
88 $list = array();
89
90 $listoffiles = array();
91 if (!empty($conf->modules_parts['printing'])) {
92 $dirmodels = array_merge(array('/core/modules/printing/'), (array) $conf->modules_parts['printing']);
93 } else {
94 $dirmodels = array('/core/modules/printing/');
95 }
96 foreach ($dirmodels as $dir) {
97 $tmpfiles = dol_dir_list(dol_buildpath($dir, 0), 'all', 0, '\.modules.php', '', 'name', SORT_ASC, 0);
98 if (!empty($tmpfiles)) {
99 $listoffiles = array_merge($listoffiles, $tmpfiles);
100 }
101 }
102 foreach ($listoffiles as $record) {
103 $list[$record['fullname']] = str_replace('.modules.php', '', $record['name']);
104 }
105 return $list;
106 }
107
113 public function getDesc()
114 {
115 global $langs;
116 $langs->load("printing");
117 $transstring = "PrintingModuleDesc".$this->name;
118 if ($langs->trans($transstring) != $transstring) {
119 return $langs->trans($transstring);
120 } else {
121 return $this->desc;
122 }
123 }
124
130 public function listAvailablePrinters()
131 {
132 $msg = get_class($this)."::".__FUNCTION__." not implemented";
133 dol_syslog($msg, LOG_ERR);
134 $this->errors[] = $msg;
135 return 1;
136 }
137
143 public function getlistAvailablePrinters()
144 {
145 $msg = get_class($this)."::".__FUNCTION__." not implemented";
146 dol_syslog($msg, LOG_ERR);
147 $this->errors[] = $msg;
148 return [];
149 }
150
159 public function printFile($file, $module, $subdir = '')
160 {
161 $msg = get_class($this)."::".__FUNCTION__." not implemented";
162 dol_syslog($msg, LOG_ERR);
163 $this->errors[] = $msg;
164 return 1;
165 }
166
174 public function listJobs($module = null)
175 {
176 $msg = get_class($this)."::".__FUNCTION__." not implemented";
177 dol_syslog($msg, LOG_ERR);
178 $this->errors[] = $msg;
179 return 1;
180 }
181}
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.