26include_once DOL_DOCUMENT_ROOT.
'/core/modules/printing/modules_printing.php';
36 public $name =
'printipp';
41 public $desc =
'PrintIPPDesc';
46 public $picto =
'printer';
51 public $active =
'PRINTING_PRINTIPP';
56 public $conf = array();
91 public $errors = array();
98 const LANGFILE =
'printipp';
115 $this->
conf[] = array(
'varname'=>
'PRINTIPP_HOST',
'required'=>1,
'example'=>
'localhost',
'type'=>
'text');
116 $this->
conf[] = array(
'varname'=>
'PRINTIPP_PORT',
'required'=>1,
'example'=>
'631',
'type'=>
'text');
117 $this->
conf[] = array(
'varname'=>
'PRINTIPP_USER',
'required'=>0,
'example'=>
'',
'type'=>
'text',
'moreattributes'=>
'autocomplete="off"');
118 $this->
conf[] = array(
'varname'=>
'PRINTIPP_PASSWORD',
'required'=>0,
'example'=>
'',
'type'=>
'password',
'moreattributes'=>
'autocomplete="off"');
119 $this->
conf[] = array(
'enabled'=>1,
'type'=>
'submit');
136 include_once DOL_DOCUMENT_ROOT.
'/includes/printipp/CupsPrintIPP.php';
138 $ipp =
new CupsPrintIPP();
139 $ipp->setLog(DOL_DATA_ROOT.
'/dolibarr_printipp.log',
'file', 3);
140 $ipp->setHost($this->host);
141 $ipp->setPort($this->port);
142 $ipp->setJobName($file,
true);
143 $ipp->setUserName($this->userid);
146 if (!empty($this->
user)) {
147 $ipp->setAuthentication($this->
user, $this->password);
151 $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);
152 $result = $this->db->query($sql);
154 $obj = $this->db->fetch_object($result);
156 dol_syslog(
"Found a default printer for user ".$user->id.
" = ".$obj->printer_id);
157 $ipp->setPrinterURI($obj->printer_id);
159 $ipp->setCopies($obj->copy);
165 $this->errors[] =
'NoDefaultPrinterDefined';
174 $fileprint = $conf->{$module}->dir_output;
176 $fileprint .=
'/'.$subdir;
178 $fileprint .=
'/'.$file;
179 $ipp->setData($fileprint);
183 $this->errors[] = $e->getMessage();
187 $this->errors[] =
'PRINTIPP: Job added';
200 global $conf, $langs;
203 $html =
'<tr class="liste_titre">';
204 $html .=
'<td>'.$langs->trans(
'IPP_Uri').
'</td>';
205 $html .=
'<td>'.$langs->trans(
'IPP_Name').
'</td>';
206 $html .=
'<td>'.$langs->trans(
'IPP_State').
'</td>';
207 $html .=
'<td>'.$langs->trans(
'IPP_State_reason').
'</td>';
208 $html .=
'<td>'.$langs->trans(
'IPP_State_reason1').
'</td>';
209 $html .=
'<td>'.$langs->trans(
'IPP_BW').
'</td>';
210 $html .=
'<td>'.$langs->trans(
'IPP_Color').
'</td>';
212 $html .=
'<td>'.$langs->trans(
'IPP_Media').
'</td>';
213 $html .=
'<td>'.$langs->trans(
'IPP_Supported').
'</td>';
214 $html .=
'<td class="center">'.$langs->trans(
"Select").
'</td>';
216 $list = $this->getlistAvailablePrinters();
217 foreach ($list as $value) {
218 $printer_det = $this->getPrinterDetail($value);
219 $html .=
'<tr class="oddeven">';
220 $html .=
'<td>'.$value.
'</td>';
222 $html .=
'<td>'.$printer_det->printer_name->_value0.
'</td>';
223 $html .=
'<td>'.$langs->trans(
'STATE_IPP_'.$printer_det->printer_state->_value0).
'</td>';
224 $html .=
'<td>'.$langs->trans(
'STATE_IPP_'.$printer_det->printer_state_reasons->_value0).
'</td>';
225 $html .=
'<td>'.(!empty($printer_det->printer_state_reasons->_value1) ? $langs->trans(
'STATE_IPP_'.$printer_det->printer_state_reasons->_value1) :
'').
'</td>';
226 $html .=
'<td>'.$langs->trans(
'IPP_COLOR_'.$printer_det->printer_type->_value2).
'</td>';
227 $html .=
'<td>'.$langs->trans(
'IPP_COLOR_'.$printer_det->printer_type->_value3).
'</td>';
229 $html .=
'<td>'.$printer_det->media_default->_value0.
'</td>';
230 $html .=
'<td>'.$langs->trans(
'MEDIA_IPP_'.$printer_det->media_type_supported->_value1).
'</td>';
232 $html .=
'<td class="center">';
233 if ($conf->global->PRINTIPP_URI_DEFAULT == $value) {
234 $html .=
img_picto($langs->trans(
"Default"),
'on');
236 $html .=
'<a href="'.$_SERVER[
"PHP_SELF"].
'?action=setvalue&token='.newToken().
'&mode=test&varname=PRINTIPP_URI_DEFAULT&driver=printipp&value='.urlencode($value).
'" alt="'.$langs->trans(
"Default").
'">'.
img_picto($langs->trans(
"Disabled"),
'off').
'</a>';
239 $html .=
'</tr>'.
"\n";
241 $this->resprint = $html;
253 include_once DOL_DOCUMENT_ROOT.
'/includes/printipp/CupsPrintIPP.php';
254 $ipp =
new CupsPrintIPP();
255 $ipp->setLog(DOL_DATA_ROOT.
'/dolibarr_printipp.log',
'file', 3);
256 $ipp->setHost($this->host);
257 $ipp->setPort($this->port);
258 $ipp->setUserName($this->userid);
259 if (!empty($this->
user)) {
260 $ipp->setAuthentication($this->
user, $this->password);
263 return $ipp->available_printers;
276 include_once DOL_DOCUMENT_ROOT.
'/includes/printipp/CupsPrintIPP.php';
277 $ipp =
new CupsPrintIPP();
278 $ipp->setLog(DOL_DATA_ROOT.
'/dolibarr_printipp.log',
'file', 3);
279 $ipp->setHost($this->host);
280 $ipp->setPort($this->port);
281 $ipp->setUserName($this->userid);
282 if (!empty($this->
user)) {
283 $ipp->setAuthentication($this->
user, $this->password);
285 $ipp->setPrinterURI($uri);
286 $ipp->getPrinterAttributes();
287 return $ipp->printer_attributes;
302 include_once DOL_DOCUMENT_ROOT.
'/includes/printipp/CupsPrintIPP.php';
303 $ipp =
new CupsPrintIPP();
304 $ipp->setLog(DOL_DATA_ROOT.
'/dolibarr_printipp.log',
'file', 3);
305 $ipp->setHost($this->host);
306 $ipp->setPort($this->port);
307 $ipp->setUserName($this->userid);
308 if (!empty($this->
user)) {
309 $ipp->setAuthentication($this->
user, $this->password);
312 $sql =
"SELECT rowid,printer_uri,printer_name FROM ".MAIN_DB_PREFIX.
"printer_ipp WHERE module = '".$this->db->escape($module).
"'";
313 $result = $this->db->query($sql);
315 $obj = $this->db->fetch_object($result);
317 $ipp->setPrinterURI($obj->printer_uri);
320 $ipp->setPrinterURI(
"ipp://localhost:631/printers/");
325 $ipp->getJobs(
false, 0,
'completed',
false);
327 $this->errors[] = $e->getMessage();
330 $html .=
'<table width="100%" class="noborder">';
331 $html .=
'<tr class="liste_titre">';
332 $html .=
'<td>Id</td>';
333 $html .=
'<td>Owner</td>';
334 $html .=
'<td>Printer</td>';
335 $html .=
'<td>File</td>';
336 $html .=
'<td>Status</td>';
337 $html .=
'<td>Cancel</td>';
338 $html .=
'</tr>'.
"\n";
339 $jobs = $ipp->jobs_attributes;
342 foreach ($jobs as $value) {
343 $html .=
'<tr class="oddeven">';
344 $html .=
'<td>'.$value->job_id->_value0.
'</td>';
345 $html .=
'<td>'.$value->job_originating_user_name->_value0.
'</td>';
346 $html .=
'<td>'.$value->printer_uri->_value0.
'</td>';
347 $html .=
'<td>'.$value->job_name->_value0.
'</td>';
348 $html .=
'<td>'.$value->job_state->_value0.
'</td>';
349 $html .=
'<td>'.$value->job_uri->_value0.
'</td>';
353 $this->resprint = $html;
Parent class of emailing target selectors modules.
Class to provide printing with PrintIPP.
getPrinterDetail($uri)
Get printer detail.
printFile($file, $module, $subdir='')
Print selected file.
__construct($db)
Constructor.
listAvailablePrinters()
Return list of available printers.
listJobs($module)
List jobs print.
getlistAvailablePrinters()
Return list of available printers.
dol_print_error($db='', $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
getDolGlobalString($key, $default='')
Return 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)