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();
97 public $errors = array();
120 $this->
conf[] = array(
'varname' =>
'PRINTIPP_HOST',
'required' => 1,
'example' =>
'localhost',
'type' =>
'text');
121 $this->
conf[] = array(
'varname' =>
'PRINTIPP_PORT',
'required' => 1,
'example' =>
'631',
'type' =>
'text');
122 $this->
conf[] = array(
'varname' =>
'PRINTIPP_USER',
'required' => 0,
'example' =>
'',
'type' =>
'text',
'moreattributes' =>
'autocomplete="off"');
123 $this->
conf[] = array(
'varname' =>
'PRINTIPP_PASSWORD',
'required' => 0,
'example' =>
'',
'type' =>
'password',
'moreattributes' =>
'autocomplete="off"');
124 $this->
conf[] = array(
'varname' =>
'PRINTIPP_SSL',
'required' => 0,
'example' =>
'',
'type' =>
'checkbox',
'moreattributes' =>
'autocomplete="off"');
125 $this->
conf[] = array(
'enabled' => 1,
'type' =>
'submit');
142 include_once DOL_DOCUMENT_ROOT.
'/includes/printipp/CupsPrintIPP.php';
144 $ipp =
new CupsPrintIPP();
145 $ipp->setLog(DOL_DATA_ROOT.
'/dolibarr_printipp.log',
'file', 3);
146 $ipp->setHost($this->host);
147 $ipp->setPort($this->port);
148 $ipp->ssl = $this->ssl;
149 $ipp->setJobName($file,
true);
150 $ipp->setUserName($this->userid);
153 if (!empty($this->
user)) {
154 $ipp->setAuthentication($this->
user, $this->password);
158 $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);
159 $result = $this->db->query($sql);
161 $obj = $this->db->fetch_object($result);
163 dol_syslog(
"Found a default printer for user ".$user->id.
" = ".$obj->printer_id);
164 $ipp->setPrinterURI($obj->printer_id);
166 $ipp->setCopies($obj->copy);
172 $this->errors[] =
'NoDefaultPrinterDefined';
181 $fileprint = $conf->{$module}->dir_output;
183 $fileprint .=
'/'.$subdir;
185 $fileprint .=
'/'.$file;
186 $ipp->setData($fileprint);
190 $this->errors[] = $e->getMessage();
194 $this->errors[] =
'PRINTIPP: Job added';
209 global $conf, $langs;
212 $html =
'<tr class="liste_titre">';
213 $html .=
'<td>'.$langs->trans(
'IPP_Uri').
'</td>';
214 $html .=
'<td>'.$langs->trans(
'IPP_Name').
'</td>';
215 $html .=
'<td>'.$langs->trans(
'IPP_State').
'</td>';
216 $html .=
'<td>'.$langs->trans(
'IPP_State_reason').
'</td>';
217 $html .=
'<td>'.$langs->trans(
'IPP_State_reason1').
'</td>';
218 $html .=
'<td>'.$langs->trans(
'IPP_BW').
'</td>';
219 $html .=
'<td>'.$langs->trans(
'IPP_Color').
'</td>';
221 $html .=
'<td>'.$langs->trans(
'IPP_Media').
'</td>';
222 $html .=
'<td>'.$langs->trans(
'IPP_Supported').
'</td>';
223 $html .=
'<td class="center">'.$langs->trans(
"Select").
'</td>';
225 $list = $this->getlistAvailablePrinters();
226 foreach ($list as $value) {
227 $printer_det = $this->getPrinterDetail($value);
228 '@phan-var-force stdClass $printer_det';
229 $html .=
'<tr class="oddeven">';
230 $html .=
'<td>'.$value.
'</td>';
232 $html .=
'<td>'.$printer_det->printer_name->_value0.
'</td>';
233 $html .=
'<td>'.$langs->trans(
'STATE_IPP_'.$printer_det->printer_state->_value0).
'</td>';
234 $html .=
'<td>'.$langs->trans(
'STATE_IPP_'.$printer_det->printer_state_reasons->_value0).
'</td>';
235 $html .=
'<td>'.(!empty($printer_det->printer_state_reasons->_value1) ? $langs->trans(
'STATE_IPP_'.$printer_det->printer_state_reasons->_value1) :
'').
'</td>';
236 $html .=
'<td>'.$langs->trans(
'IPP_COLOR_'.$printer_det->printer_type->_value2).
'</td>';
237 $html .=
'<td>'.$langs->trans(
'IPP_COLOR_'.$printer_det->printer_type->_value3).
'</td>';
239 $html .=
'<td>'.$printer_det->media_default->_value0.
'</td>';
240 $html .=
'<td>'.$langs->trans(
'MEDIA_IPP_'.$printer_det->media_type_supported->_value1).
'</td>';
242 $html .=
'<td class="center">';
243 if ($conf->global->PRINTIPP_URI_DEFAULT == $value) {
244 $html .=
img_picto($langs->trans(
"Default"),
'on');
246 $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>';
249 $html .=
'</tr>'.
"\n";
251 $this->resprint = $html;
263 include_once DOL_DOCUMENT_ROOT.
'/includes/printipp/CupsPrintIPP.php';
264 $ipp =
new CupsPrintIPP();
265 $ipp->setLog(DOL_DATA_ROOT.
'/dolibarr_printipp.log',
'file', 3);
266 $ipp->setHost($this->host);
267 $ipp->setPort($this->port);
268 $ipp->setUserName($this->userid);
269 if (!empty($this->
user)) {
270 $ipp->setAuthentication($this->
user, $this->password);
273 return $ipp->available_printers;
286 include_once DOL_DOCUMENT_ROOT.
'/includes/printipp/CupsPrintIPP.php';
287 $ipp =
new CupsPrintIPP();
288 $ipp->setLog(DOL_DATA_ROOT.
'/dolibarr_printipp.log',
'file', 3);
289 $ipp->setHost($this->host);
290 $ipp->setPort($this->port);
291 $ipp->setUserName($this->userid);
292 if (!empty($this->
user)) {
293 $ipp->setAuthentication($this->
user, $this->password);
295 $ipp->setPrinterURI($uri);
296 $ipp->getPrinterAttributes();
297 return $ipp->printer_attributes;
312 include_once DOL_DOCUMENT_ROOT.
'/includes/printipp/CupsPrintIPP.php';
313 $ipp =
new CupsPrintIPP();
314 $ipp->setLog(DOL_DATA_ROOT.
'/dolibarr_printipp.log',
'file', 3);
315 $ipp->setHost($this->host);
316 $ipp->setPort($this->port);
317 $ipp->setUserName($this->userid);
318 if (!empty($this->
user)) {
319 $ipp->setAuthentication($this->
user, $this->password);
322 $sql =
"SELECT rowid,printer_uri,printer_name FROM ".MAIN_DB_PREFIX.
"printer_ipp WHERE module = '".$this->db->escape($module).
"'";
323 $result = $this->db->query($sql);
325 $obj = $this->db->fetch_object($result);
327 $ipp->setPrinterURI($obj->printer_uri);
330 $ipp->setPrinterURI(
"ipp://localhost:631/printers/");
335 $ipp->getJobs(
false, 0,
'completed',
false);
337 $this->errors[] = $e->getMessage();
340 $html .=
'<table width="100%" class="noborder">';
341 $html .=
'<tr class="liste_titre">';
342 $html .=
'<td>Id</td>';
343 $html .=
'<td>Owner</td>';
344 $html .=
'<td>Printer</td>';
345 $html .=
'<td>File</td>';
346 $html .=
'<td>Status</td>';
347 $html .=
'<td>Cancel</td>';
348 $html .=
'</tr>'.
"\n";
349 $jobs = $ipp->jobs_attributes;
352 foreach ($jobs as $value) {
353 $html .=
'<tr class="oddeven">';
354 $html .=
'<td>'.$value->job_id->_value0.
'</td>';
355 $html .=
'<td>'.$value->job_originating_user_name->_value0.
'</td>';
356 $html .=
'<td>'.$value->printer_uri->_value0.
'</td>';
357 $html .=
'<td>'.$value->job_name->_value0.
'</td>';
358 $html .=
'<td>'.$value->job_state->_value0.
'</td>';
359 $html .=
'<td>'.$value->job_uri->_value0.
'</td>';
363 $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.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
newToken()
Return the value of token currently saved into session with name 'newtoken'.
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 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.