27include_once DOL_DOCUMENT_ROOT.
'/core/modules/printing/modules_printing.php';
37 public $name =
'printipp';
42 public $desc =
'PrintIPPDesc';
47 public $picto =
'printer';
52 public $active =
'PRINTING_PRINTIPP';
57 public $conf = array();
105 $this->
conf[] = array(
'varname' =>
'PRINTIPP_HOST',
'required' => 1,
'example' =>
'localhost',
'type' =>
'text');
106 $this->
conf[] = array(
'varname' =>
'PRINTIPP_PORT',
'required' => 1,
'example' =>
'631',
'type' =>
'text');
107 $this->
conf[] = array(
'varname' =>
'PRINTIPP_USER',
'required' => 0,
'example' =>
'',
'type' =>
'text',
'moreattributes' =>
'autocomplete="off"');
108 $this->
conf[] = array(
'varname' =>
'PRINTIPP_PASSWORD',
'required' => 0,
'example' =>
'',
'type' =>
'password',
'moreattributes' =>
'autocomplete="off"');
109 $this->
conf[] = array(
'varname' =>
'PRINTIPP_SSL',
'required' => 0,
'example' =>
'',
'type' =>
'checkbox',
'moreattributes' =>
'autocomplete="off"');
110 $this->
conf[] = array(
'enabled' => 1,
'type' =>
'submit');
127 include_once DOL_DOCUMENT_ROOT.
'/includes/printipp/CupsPrintIPP.php';
129 $ipp =
new CupsPrintIPP();
130 $ipp->setLog(DOL_DATA_ROOT.
'/dolibarr_printipp.log',
'file', 3);
131 $ipp->setHost($this->host);
132 $ipp->setPort($this->port);
133 $ipp->ssl = $this->ssl;
134 $ipp->setJobName($file,
true);
135 $ipp->setUserName($this->userid);
138 if (!empty($this->
user)) {
139 $ipp->setAuthentication($this->
user, $this->password);
143 $sql =
"SELECT rowid,printer_id,copy FROM ".MAIN_DB_PREFIX.
"printing WHERE module = '".$this->db->escape($module).
"' AND driver = 'printipp' AND userid = ".((int) $user->id);
144 $result = $this->db->query($sql);
146 $obj = $this->db->fetch_object($result);
148 dol_syslog(
"Found a default printer for user ".$user->id.
" = ".$obj->printer_id);
149 $ipp->setPrinterURI($obj->printer_id);
151 $ipp->setCopies($obj->copy);
157 $this->errors[] =
'NoDefaultPrinterDefined';
167 $ipp->setData($fileprint);
169 $extension = strtolower(pathinfo($fileprint, PATHINFO_EXTENSION));
171 'pdf' =>
'application/pdf',
172 'odt' =>
'application/vnd.oasis.opendocument.text',
173 'ods' =>
'application/vnd.oasis.opendocument.spreadsheet',
174 'odp' =>
'application/vnd.oasis.opendocument.presentation',
175 'ps' =>
'application/postscript',
176 'eps' =>
'application/postscript',
177 'txt' =>
'text/plain',
178 'png' =>
'image/png',
179 'jpg' =>
'image/jpeg',
180 'jpeg' =>
'image/jpeg',
182 if (isset($mimebyext[$extension])) {
183 $ipp->setMimeMediaType($mimebyext[$extension]);
188 $this->errors[] = $e->getMessage();
192 $this->errors[] =
'PRINTIPP: Job added';
207 global $conf, $langs;
210 $html =
'<tr class="liste_titre">';
211 $html .=
'<td>'.$langs->trans(
'IPP_Uri').
'</td>';
212 $html .=
'<td>'.$langs->trans(
'IPP_Name').
'</td>';
213 $html .=
'<td>'.$langs->trans(
'IPP_State').
'</td>';
214 $html .=
'<td>'.$langs->trans(
'IPP_State_reason').
'</td>';
215 $html .=
'<td>'.$langs->trans(
'IPP_State_reason1').
'</td>';
216 $html .=
'<td>'.$langs->trans(
'IPP_BW').
'</td>';
217 $html .=
'<td>'.$langs->trans(
'IPP_Color').
'</td>';
219 $html .=
'<td>'.$langs->trans(
'IPP_Media').
'</td>';
220 $html .=
'<td>'.$langs->trans(
'IPP_Supported').
'</td>';
221 $html .=
'<td class="center">'.$langs->trans(
"Select").
'</td>';
224 foreach ($list as $value) {
226 '@phan-var-force stdClass $printer_det';
227 $html .=
'<tr class="oddeven">';
228 $html .=
'<td>'.$value.
'</td>';
230 $html .=
'<td>'.$printer_det->printer_name->_value0.
'</td>';
231 $html .=
'<td>'.$langs->trans(
'STATE_IPP_'.$printer_det->printer_state->_value0).
'</td>';
232 $html .=
'<td>'.$langs->trans(
'STATE_IPP_'.$printer_det->printer_state_reasons->_value0).
'</td>';
233 $html .=
'<td>'.(!empty($printer_det->printer_state_reasons->_value1) ? $langs->trans(
'STATE_IPP_'.$printer_det->printer_state_reasons->_value1) :
'').
'</td>';
234 $html .=
'<td>'.(!empty($printer_det->printer_type->_value2) ? $langs->trans(
'IPP_COLOR_'.$printer_det->printer_type->_value2) :
'').
'</td>';
235 $html .=
'<td>'.(!empty($printer_det->printer_type->_value3) ? $langs->trans(
'IPP_COLOR_'.$printer_det->printer_type->_value3) :
'').
'</td>';
237 $html .=
'<td>'.$printer_det->media_default->_value0.
'</td>';
238 $html .=
'<td>'.(!empty($printer_det->media_type_supported->_value1) ? $langs->trans(
'MEDIA_IPP_'.$printer_det->media_type_supported->_value1) :
'').
'</td>';
240 $html .=
'<td class="center">';
242 $html .=
img_picto($langs->trans(
"Default"),
'on');
244 $html .=
'<a href="'.dolBuildUrl($_SERVER[
"PHP_SELF"], [
'action' =>
'setvalue',
'mode' =>
'test',
'varname' =>
'PRINTIPP_URI_DEFAULT',
'driver' =>
'printipp',
'value' => $value],
true).
'" alt="'.$langs->trans(
"Default").
'">'.
img_picto($langs->trans(
"Disabled"),
'off').
'</a>';
247 $html .=
'</tr>'.
"\n";
249 $this->resprint = $html;
260 include_once DOL_DOCUMENT_ROOT.
'/includes/printipp/CupsPrintIPP.php';
261 $ipp =
new CupsPrintIPP();
262 $ipp->setLog(DOL_DATA_ROOT.
'/dolibarr_printipp.log',
'file', 3);
263 $ipp->setHost($this->host);
264 $ipp->setPort($this->port);
265 $ipp->setUserName($this->userid);
266 if (!empty($this->
user)) {
267 $ipp->setAuthentication($this->
user, $this->password);
275 return $ipp->available_printers;
288 include_once DOL_DOCUMENT_ROOT.
'/includes/printipp/CupsPrintIPP.php';
289 $ipp =
new CupsPrintIPP();
290 $ipp->setLog(DOL_DATA_ROOT.
'/dolibarr_printipp.log',
'file', 3);
291 $ipp->setHost($this->host);
292 $ipp->setPort($this->port);
293 $ipp->setUserName($this->userid);
294 if (!empty($this->
user)) {
295 $ipp->setAuthentication($this->
user, $this->password);
297 $ipp->setPrinterURI($uri);
298 $ipp->getPrinterAttributes();
299 return $ipp->printer_attributes;
315 include_once DOL_DOCUMENT_ROOT.
'/includes/printipp/CupsPrintIPP.php';
316 $ipp =
new CupsPrintIPP();
317 $ipp->setLog(DOL_DATA_ROOT.
'/dolibarr_printipp.log',
'file', 3);
318 $ipp->setHost($this->host);
319 $ipp->setPort($this->port);
320 $ipp->setUserName($this->userid);
321 if (!empty($this->
user)) {
322 $ipp->setAuthentication($this->
user, $this->password);
325 $sql =
"SELECT rowid, printer_uri, printer_name";
326 $sql .=
" FROM ".MAIN_DB_PREFIX.
"printer_ipp WHERE module = '".$this->db->escape((
string) $module).
"'";
327 $result = $this->db->query($sql);
329 $obj = $this->db->fetch_object($result);
331 $ipp->setPrinterURI($obj->printer_uri);
334 $ipp->setPrinterURI(
"ipp://localhost:631/printers/");
339 $ipp->getJobs(
false, 0,
'completed',
false);
341 $this->errors[] = $e->getMessage();
344 $html .=
'<table width="100%" class="noborder">';
345 $html .=
'<tr class="liste_titre">';
346 $html .=
'<td>ID</td>';
347 $html .=
'<td>'.$langs->trans(
"Date").
'</td>';
348 $html .=
'<td>'.$langs->trans(
"Owner").
'</td>';
349 $html .=
'<td>'.$langs->trans(
"Printer").
'</td>';
350 $html .=
'<td>'.$langs->trans(
"File").
'</td>';
351 $html .=
'<td>'.$langs->trans(
"Status").
'</td>';
352 $html .=
'<td>Job URI</td>';
353 $html .=
'</tr>'.
"\n";
355 $jobs = $ipp->jobs_attributes;
359 foreach ($jobs as $value) {
360 $html .=
'<tr class="oddeven">';
361 $html .=
'<td>'.$value->job_id->_value0.
'</td>';
362 $html .=
'<td>'.$value->date_time_at_creation->_value0.
'</td>';
363 $html .=
'<td>'.$value->job_originating_user_name->_value0.
'</td>';
364 $html .=
'<td>'.$value->job_printer_uri->_value0.
'</td>';
365 $file = $value->job_name->_value0;
366 $html .=
'<td class="tdoverflowmax200" title="'.dolPrintHTMLForAttribute($file).
'">'.
dolPrintHTML($file).
'</td>';
367 $html .=
'<td>'.$value->job_state->_value0.
'</td>';
368 $html .=
'<td>'.$value->job_uri->_value0.
'</td>';
372 $this->resprint = $html;
Parent class of emailing target selectors modules.
Class to provide printing with PrintIPP.
getPrinterDetail($uri)
Get printer detail.
listJobs($module=null)
List jobs print.
printFile($file, $module, $subdir='')
Print selected file.
__construct($db)
Constructor.
listAvailablePrinters()
Return list of available printers.
getlistAvailablePrinters()
Return list of available printers.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2, $allowothertags=array())
Show picto whatever it's its name (generic function)
dolPrintHTML($s, $allowiframe=0, $moreallowedtags=array())
Return a string (that can be on several lines) ready to be output on a HTML page.
setEventMessage($mesgs, $style='mesgs', $noduplicate=0, $attop=0)
Set event message in dol_events session object.
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
getMultidirOutput($object, $module='', $forobject=0, $mode='output')
Return the full path of the directory where a module (or an object of a module) stores its files.
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 a Dolibarr global constant string value.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
conf($dolibarr_main_document_root)
Load conf file (file must exists)
$conf db user
Active Directory does not allow anonymous connections.