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';
166 $fileprint =
$conf->{$module}->dir_output;
168 $fileprint .=
'/'.$subdir;
170 $fileprint .=
'/'.$file;
171 $ipp->setData($fileprint);
175 $this->errors[] = $e->getMessage();
179 $this->errors[] =
'PRINTIPP: Job added';
194 global
$conf, $langs;
197 $html =
'<tr class="liste_titre">';
198 $html .=
'<td>'.$langs->trans(
'IPP_Uri').
'</td>';
199 $html .=
'<td>'.$langs->trans(
'IPP_Name').
'</td>';
200 $html .=
'<td>'.$langs->trans(
'IPP_State').
'</td>';
201 $html .=
'<td>'.$langs->trans(
'IPP_State_reason').
'</td>';
202 $html .=
'<td>'.$langs->trans(
'IPP_State_reason1').
'</td>';
203 $html .=
'<td>'.$langs->trans(
'IPP_BW').
'</td>';
204 $html .=
'<td>'.$langs->trans(
'IPP_Color').
'</td>';
206 $html .=
'<td>'.$langs->trans(
'IPP_Media').
'</td>';
207 $html .=
'<td>'.$langs->trans(
'IPP_Supported').
'</td>';
208 $html .=
'<td class="center">'.$langs->trans(
"Select").
'</td>';
210 $list = $this->getlistAvailablePrinters();
211 foreach ($list as $value) {
212 $printer_det = $this->getPrinterDetail($value);
213 '@phan-var-force stdClass $printer_det';
214 $html .=
'<tr class="oddeven">';
215 $html .=
'<td>'.$value.
'</td>';
217 $html .=
'<td>'.$printer_det->printer_name->_value0.
'</td>';
218 $html .=
'<td>'.$langs->trans(
'STATE_IPP_'.$printer_det->printer_state->_value0).
'</td>';
219 $html .=
'<td>'.$langs->trans(
'STATE_IPP_'.$printer_det->printer_state_reasons->_value0).
'</td>';
220 $html .=
'<td>'.(!empty($printer_det->printer_state_reasons->_value1) ? $langs->trans(
'STATE_IPP_'.$printer_det->printer_state_reasons->_value1) :
'').
'</td>';
221 $html .=
'<td>'.$langs->trans(
'IPP_COLOR_'.$printer_det->printer_type->_value2).
'</td>';
222 $html .=
'<td>'.$langs->trans(
'IPP_COLOR_'.$printer_det->printer_type->_value3).
'</td>';
224 $html .=
'<td>'.$printer_det->media_default->_value0.
'</td>';
225 $html .=
'<td>'.$langs->trans(
'MEDIA_IPP_'.$printer_det->media_type_supported->_value1).
'</td>';
227 $html .=
'<td class="center">';
228 if (
$conf->global->PRINTIPP_URI_DEFAULT == $value) {
229 $html .=
img_picto($langs->trans(
"Default"),
'on');
231 $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>';
234 $html .=
'</tr>'.
"\n";
236 $this->resprint = $html;
248 include_once DOL_DOCUMENT_ROOT.
'/includes/printipp/CupsPrintIPP.php';
249 $ipp =
new CupsPrintIPP();
250 $ipp->setLog(DOL_DATA_ROOT.
'/dolibarr_printipp.log',
'file', 3);
251 $ipp->setHost($this->host);
252 $ipp->setPort($this->port);
253 $ipp->setUserName($this->userid);
254 if (!empty($this->
user)) {
255 $ipp->setAuthentication($this->
user, $this->password);
258 return $ipp->available_printers;
271 include_once DOL_DOCUMENT_ROOT.
'/includes/printipp/CupsPrintIPP.php';
272 $ipp =
new CupsPrintIPP();
273 $ipp->setLog(DOL_DATA_ROOT.
'/dolibarr_printipp.log',
'file', 3);
274 $ipp->setHost($this->host);
275 $ipp->setPort($this->port);
276 $ipp->setUserName($this->userid);
277 if (!empty($this->
user)) {
278 $ipp->setAuthentication($this->
user, $this->password);
280 $ipp->setPrinterURI($uri);
281 $ipp->getPrinterAttributes();
282 return $ipp->printer_attributes;
298 include_once DOL_DOCUMENT_ROOT.
'/includes/printipp/CupsPrintIPP.php';
299 $ipp =
new CupsPrintIPP();
300 $ipp->setLog(DOL_DATA_ROOT.
'/dolibarr_printipp.log',
'file', 3);
301 $ipp->setHost($this->host);
302 $ipp->setPort($this->port);
303 $ipp->setUserName($this->userid);
304 if (!empty($this->
user)) {
305 $ipp->setAuthentication($this->
user, $this->password);
308 $sql =
"SELECT rowid, printer_uri, printer_name";
309 $sql .=
" FROM ".MAIN_DB_PREFIX.
"printer_ipp WHERE module = '".$this->db->escape((
string) $module).
"'";
310 $result = $this->db->query($sql);
312 $obj = $this->db->fetch_object($result);
314 $ipp->setPrinterURI($obj->printer_uri);
317 $ipp->setPrinterURI(
"ipp://localhost:631/printers/");
322 $ipp->getJobs(
false, 0,
'completed',
false);
324 $this->errors[] = $e->getMessage();
327 $html .=
'<table width="100%" class="noborder">';
328 $html .=
'<tr class="liste_titre">';
329 $html .=
'<td>ID</td>';
330 $html .=
'<td>'.$langs->trans(
"Date").
'</td>';
331 $html .=
'<td>'.$langs->trans(
"Owner").
'</td>';
332 $html .=
'<td>'.$langs->trans(
"Printer").
'</td>';
333 $html .=
'<td>'.$langs->trans(
"File").
'</td>';
334 $html .=
'<td>'.$langs->trans(
"Status").
'</td>';
335 $html .=
'<td>Job URI</td>';
336 $html .=
'</tr>'.
"\n";
338 $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->date_time_at_creation->_value0.
'</td>';
346 $html .=
'<td>'.$value->job_originating_user_name->_value0.
'</td>';
347 $html .=
'<td>'.$value->job_printer_uri->_value0.
'</td>';
348 $file = $value->job_name->_value0;
349 $html .=
'<td class="tdoverflowmax200" title="'.dolPrintHTMLForAttribute($file).
'">'.
dolPrintHTML($file).
'</td>';
350 $html .=
'<td>'.$value->job_state->_value0.
'</td>';
351 $html .=
'<td>'.$value->job_uri->_value0.
'</td>';
355 $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)
Show picto whatever it's its name (generic function)
dolPrintHTML($s, $allowiframe=0)
Return a string (that can be on several lines) ready to be output on a HTML page.
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 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)
global $conf
The following vars must be defined: $type2label $form $conf, $lang, The following vars may also be de...
$conf db user
Active Directory does not allow anonymous connections.