/** * List jobs print * * @param string $module module * * @return void */ function list_jobs($module) { global $conf, $db, $bc, $langs; include_once DOL_DOCUMENT_ROOT . '/includes/printipp/CupsPrintIPP.php'; $ipp = new CupsPrintIPP(); $ipp->setLog(DOL_DATA_ROOT . '/printipp.log', 'file', 3); // logging very verbose $ipp->setHost($this->host); $ipp->setPort($this->port); $ipp->setUserName($this->userid); if (!empty($this->user)) { $ipp->setAuthentication($this->user, $this->password); } // select printer uri for module order, propal,... $sql = 'SELECT rowid,printer_uri,printer_name FROM ' . MAIN_DB_PREFIX . 'printer_ipp WHERE module="' . $module . '"'; $result = $this->db->query($sql); if ($result) { $obj = $this->db->fetch_object($result); if ($obj) { $ipp->setPrinterURI($obj->printer_uri); } else { // All printers $ipp->setPrinterURI("ipp://localhost:631/printers/"); } } // Getting Jobs try { $ipp->getJobs(false, 0, 'completed', false); // May return errors if setup not correct } catch (Exception $e) { setEventMessage('[printipp] ' . $langs->trans('CoreErrorMessage'), 'errors'); dol_syslog($e->getMessage(), LOG_ERR); } print '<table width="100%" class="noborder">'; print '<tr class="liste_titre">'; print "<td>Id</td>"; print "<td>Owner</td>"; print "<td>Printer</td>"; print "<td>File</td>"; print "<td>Status</td>"; print "<td>Cancel</td>"; print "</tr>\n"; $jobs = $ipp->jobs_attributes; $var = true; //print '<pre>'.print_r($jobs,true).'</pre>'; if (is_array($jobs)) { foreach ($jobs as $value) { $var = !$var; print "<tr " . $bc[$var] . ">"; print '<td>' . $value->job_id->_value0 . '</td>'; print '<td>' . $value->job_originating_user_name->_value0 . '</td>'; print '<td>' . $value->printer_uri->_value0 . '</td>'; print '<td>' . $value->job_name->_value0 . '</td>'; print '<td>' . $value->job_state->_value0 . '</td>'; print '<td>' . $value->job_uri->_value0 . '</td>'; print '</tr>'; } } print "</table>"; }
/** * List jobs print * * @param string $module module * * @return int 0 if OK, >0 if KO */ function list_jobs($module) { global $conf, $db, $bc; $error = 0; $html = ''; include_once DOL_DOCUMENT_ROOT . '/includes/printipp/CupsPrintIPP.php'; $ipp = new CupsPrintIPP(); $ipp->setLog(DOL_DATA_ROOT . '/dolibarr_printipp.log', 'file', 3); // logging very verbose $ipp->setHost($this->host); $ipp->setPort($this->port); $ipp->setUserName($this->userid); if (!empty($this->user)) { $ipp->setAuthentication($this->user, $this->password); } // select printer uri for module order, propal,... $sql = 'SELECT rowid,printer_uri,printer_name FROM ' . MAIN_DB_PREFIX . 'printer_ipp WHERE module="' . $module . '"'; $result = $this->db->query($sql); if ($result) { $obj = $this->db->fetch_object($result); if ($obj) { $ipp->setPrinterURI($obj->printer_uri); } else { // All printers $ipp->setPrinterURI("ipp://localhost:631/printers/"); } } // Getting Jobs try { $ipp->getJobs(false, 0, 'completed', false); } catch (Exception $e) { $this->errors[] = $e->getMessage(); $error++; } $html .= '<table width="100%" class="noborder">'; $html .= '<tr class="liste_titre">'; $html .= '<td>Id</td>'; $html .= '<td>Owner</td>'; $html .= '<td>Printer</td>'; $html .= '<td>File</td>'; $html .= '<td>Status</td>'; $html .= '<td>Cancel</td>'; $html .= '</tr>' . "\n"; $jobs = $ipp->jobs_attributes; $var = True; //$html .= '<pre>'.print_r($jobs,true).'</pre>'; foreach ($jobs as $value) { $var = !$var; $html .= '<tr ' . $bc[$var] . '>'; $html .= '<td>' . $value->job_id->_value0 . '</td>'; $html .= '<td>' . $value->job_originating_user_name->_value0 . '</td>'; $html .= '<td>' . $value->printer_uri->_value0 . '</td>'; $html .= '<td>' . $value->job_name->_value0 . '</td>'; $html .= '<td>' . $value->job_state->_value0 . '</td>'; $html .= '<td>' . $value->job_uri->_value0 . '</td>'; $html .= '</tr>'; } $html .= "</table>"; $this->resprint = $html; return $error; }
// logging very verbose $ipp->setHost("localhost"); $ipp->ssl = $ssl; //$ipp->setHost("toto");// Resistance test $ipp->setHost($host); //Put your printer IP or hostname/fqdn here $ipp->setPrinterURI($printer_uri); // Set printer URI here //$ipp->setPrinterURI("ipp://localhost:631/printers/epson"); // Set printer URI here //$ipp->setPrinterURI("/printers/foo"); // => abort "client-error-not-found" $ipp->setUserName("php IPP tester"); $ipp->setFidelity(); // printing abort if every attribute could not be set on printer. NOTE: CUPS do not abort :) $ipp->setCharset('utf-8'); $ipp->setLanguage($language); $ipp->setAuthentication($user, $password); // username & password $j = 0; $test = 1; /* printing a large file */ echo "<br /><br /><br />TEST 1<br />"; echo "OPERATION " . $j++ . "<br />"; $ipp->setAttribute("printer-resolution", "1440x720dpi"); $ipp->setAttribute("job-billing", "Thomas"); $ipp->setAttribute("print-quality", "high"); $ipp->setAttribute("scaling", 100); //$ipp->setCopies(2); $ipp->setData('./photo.jpg'); $ipp->setJobName('photo.jpg', true); echo "Printing a large file: " . $ipp->PrintJob() . "<br />"; printf('$ipp->status[0] = %s <br /><br />', $ipp->status[0]);
/** * Get printer detail * * @param string $uri URI * @return array List of attributes */ function get_printer_detail($uri) { global $conf, $db; include_once DOL_DOCUMENT_ROOT . '/includes/printipp/CupsPrintIPP.php'; $ipp = new CupsPrintIPP(); $ipp->setLog(DOL_DATA_ROOT . '/printipp.log', 'file', 3); // logging very verbose $ipp->setHost($this->host); $ipp->setPort($this->port); $ipp->setUserName($this->userid); if (!empty($this->user)) { $ipp->setAuthentication($this->user, $this->password); } $ipp->setPrinterURI($uri); $ipp->getPrinterAttributes(); return $ipp->printer_attributes; }
function initializePrinting() { require_once 'phpprintipp/CupsPrintIPP.php'; $unix = true; $ipp = new CupsPrintIPP(); //UNIX-Sockets if ($unix) { $ipp->setUnix(IPP_SERVER); } $ipp->setHost(IPP_SERVER); $ipp->setAuthentication(USER, PASS); $ipp->setUserName('GiegSports'); $ipp->setCharset('utf-8'); return $ipp; }