printing remove no camelcaps function

This commit is contained in:
Frédéric FRANCE 2018-09-13 11:13:32 +02:00
parent ca85356b45
commit 5862a5e2ee
No known key found for this signature in database
GPG Key ID: 06809324E4B2ABC1
7 changed files with 110 additions and 132 deletions

View File

@ -342,7 +342,7 @@ if ($mode == 'test' && $user->admin)
$langs->load($driver); $langs->load($driver);
$printer = new $classname($db); $printer = new $classname($db);
//print '<pre>'.print_r($printer, true).'</pre>'; //print '<pre>'.print_r($printer, true).'</pre>';
if (count($printer->getlist_available_printers())) { if (count($printer->getlistAvailablePrinters())) {
if ($printer->listAvailablePrinters()==0) { if ($printer->listAvailablePrinters()==0) {
print $printer->resprint; print $printer->resprint;
} else { } else {

View File

@ -28,8 +28,7 @@
// Filename to print must be provided into 'file' parameter // Filename to print must be provided into 'file' parameter
// Print file // Print file
if ($action == 'print_file' && $user->rights->printing->read) if ($action == 'print_file' && $user->rights->printing->read) {
{
$langs->load("printing"); $langs->load("printing");
require_once DOL_DOCUMENT_ROOT . '/core/modules/printing/modules_printing.php'; require_once DOL_DOCUMENT_ROOT . '/core/modules/printing/modules_printing.php';
$objectprint = new PrintingDriver($db); $objectprint = new PrintingDriver($db);
@ -55,7 +54,7 @@ if ($action == 'print_file' && $user->rights->printing->read)
$subdir = 'commande'; $subdir = 'commande';
} }
try { try {
$ret = $printer->print_file(GETPOST('file', 'alpha'), $module, $subdir); $ret = $printer->printFile(GETPOST('file', 'alpha'), $module, $subdir);
if ($ret > 0) { if ($ret > 0) {
//print '<pre>'.print_r($printer->errors, true).'</pre>'; //print '<pre>'.print_r($printer->errors, true).'</pre>';
setEventMessages($printer->error, $printer->errors, 'errors'); setEventMessages($printer->error, $printer->errors, 'errors');

View File

@ -46,7 +46,7 @@ class printing_printgcp extends PrintingDriver
/** /**
* @var string Error code (or message) * @var string Error code (or message)
*/ */
public $error=''; public $error = '';
/** /**
* @var string[] Error codes (or messages) * @var string[] Error codes (or messages)
@ -75,8 +75,8 @@ class printing_printgcp extends PrintingDriver
global $conf, $langs, $dolibarr_main_url_root; global $conf, $langs, $dolibarr_main_url_root;
// Define $urlwithroot // Define $urlwithroot
$urlwithouturlroot=preg_replace('/'.preg_quote(DOL_URL_ROOT,'/').'$/i','',trim($dolibarr_main_url_root)); $urlwithouturlroot = preg_replace('/'.preg_quote(DOL_URL_ROOT,'/').'$/i','',trim($dolibarr_main_url_root));
$urlwithroot=$urlwithouturlroot.DOL_URL_ROOT; // This is to use external domain name found into config file $urlwithroot = $urlwithouturlroot.DOL_URL_ROOT; // This is to use external domain name found into config file
//$urlwithroot=DOL_MAIN_URL_ROOT; // This is to use same domain name than current //$urlwithroot=DOL_MAIN_URL_ROOT; // This is to use same domain name than current
$this->db = $db; $this->db = $db;
@ -85,7 +85,7 @@ class printing_printgcp extends PrintingDriver
$this->conf[] = array( $this->conf[] = array(
'varname'=>'PRINTGCP_INFO', 'varname'=>'PRINTGCP_INFO',
'info'=>$langs->transnoentitiesnoconv("WarningModuleNotActive", "OAuth"), 'info'=>$langs->transnoentitiesnoconv("WarningModuleNotActive", "OAuth"),
'type'=>'info' 'type'=>'info',
); );
} else { } else {
@ -144,7 +144,7 @@ class printing_printgcp extends PrintingDriver
$refreshtoken = $token->getRefreshToken(); $refreshtoken = $token->getRefreshToken();
$endoflife=$token->getEndOfLife(); $endoflife = $token->getEndOfLife();
if ($endoflife == $token::EOL_NEVER_EXPIRES) if ($endoflife == $token::EOL_NEVER_EXPIRES)
{ {
@ -183,9 +183,9 @@ class printing_printgcp extends PrintingDriver
* *
* @return int 0 if OK, >0 if KO * @return int 0 if OK, >0 if KO
*/ */
function listAvailablePrinters() public function listAvailablePrinters()
{ {
global $bc, $conf, $langs; global $conf, $langs;
$error = 0; $error = 0;
$langs->load('printing'); $langs->load('printing');
@ -199,7 +199,7 @@ class printing_printgcp extends PrintingDriver
$html.= '<td>'.$langs->trans('GCP_Type').'</td>'; $html.= '<td>'.$langs->trans('GCP_Type').'</td>';
$html.= '<td align="center">'.$langs->trans("Select").'</td>'; $html.= '<td align="center">'.$langs->trans("Select").'</td>';
$html.= '</tr>'."\n"; $html.= '</tr>'."\n";
$list = $this->getlist_available_printers(); $list = $this->getlistAvailablePrinters();
//$html.= '<td><pre>'.print_r($list,true).'</pre></td>'; //$html.= '<td><pre>'.print_r($list,true).'</pre></td>';
foreach ($list['available'] as $printer_det) foreach ($list['available'] as $printer_det)
{ {
@ -227,15 +227,13 @@ class printing_printgcp extends PrintingDriver
} }
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/** /**
* Return list of available printers * Return list of available printers
* *
* @return array list of printers * @return array list of printers
*/ */
function getlist_available_printers() public function getlistAvailablePrinters()
{ {
// phpcs:enable
// Token storage // Token storage
$storage = new DoliStorage($this->db, $this->conf); $storage = new DoliStorage($this->db, $this->conf);
// Setup the credentials for the requests // Setup the credentials for the requests
@ -293,7 +291,6 @@ class printing_printgcp extends PrintingDriver
return $ret; return $ret;
} }
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/** /**
* Print selected file * Print selected file
* *
@ -302,16 +299,17 @@ class printing_printgcp extends PrintingDriver
* @param string $subdir subdir for file * @param string $subdir subdir for file
* @return int 0 if OK, >0 if KO * @return int 0 if OK, >0 if KO
*/ */
function print_file($file, $module, $subdir='') public function printFile($file, $module, $subdir='')
{ {
// phpcs:enable
require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
global $conf, $user; global $conf, $user;
$error = 0; $error = 0;
$fileprint=$conf->{$module}->dir_output; $fileprint = $conf->{$module}->dir_output;
if ($subdir!='') $fileprint.='/'.$subdir; if ($subdir!='') {
$fileprint.='/'.$subdir;
}
$fileprint.='/'.$file; $fileprint.='/'.$file;
$mimetype = dol_mimetype($fileprint); $mimetype = dol_mimetype($fileprint);
// select printer uri for module order, propal,... // select printer uri for module order, propal,...
@ -342,7 +340,9 @@ class printing_printgcp extends PrintingDriver
$ret = $this->sendPrintToPrinter($printer_id, $file, $fileprint, $mimetype); $ret = $this->sendPrintToPrinter($printer_id, $file, $fileprint, $mimetype);
$this->error = 'PRINTGCP: '.$ret['errormessage']; $this->error = 'PRINTGCP: '.$ret['errormessage'];
if ($ret['status']!=1) $error++; if ($ret['status']!=1) {
$error++;
}
return $error; return $error;
} }
@ -370,11 +370,12 @@ class printing_printgcp extends PrintingDriver
$contents = fread($handle, filesize($filepath)); $contents = fread($handle, filesize($filepath));
fclose($handle); fclose($handle);
// Prepare post fields for sending print // Prepare post fields for sending print
$post_fields = array('printerid' => $printerid, $post_fields = array(
'printerid' => $printerid,
'title' => $printjobtitle, 'title' => $printjobtitle,
'contentTransferEncoding' => 'base64', 'contentTransferEncoding' => 'base64',
'content' => base64_encode($contents), // encode file content as base64 'content' => base64_encode($contents), // encode file content as base64
'contentType' => $contenttype 'contentType' => $contenttype,
); );
// Dolibarr Token storage // Dolibarr Token storage
$storage = new DoliStorage($this->db, $this->conf); $storage = new DoliStorage($this->db, $this->conf);
@ -410,20 +411,18 @@ class printing_printgcp extends PrintingDriver
// Send a request with api // Send a request with api
$response = json_decode($apiService->request(self::PRINT_URL, 'POST', $post_fields), true); $response = json_decode($apiService->request(self::PRINT_URL, 'POST', $post_fields), true);
//print '<tr><td><pre>'.print_r($response, true).'</pre></td></tr>'; //print '<tr><td><pre>'.print_r($response, true).'</pre></td></tr>';
return array('status' =>$response['success'],'errorcode' =>$response['errorCode'],'errormessage'=>$response['message']); return array('status' => $response['success'], 'errorcode' => $response['errorCode'], 'errormessage' => $response['message']);
} }
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/** /**
* List jobs print * List jobs print
* *
* @return int 0 if OK, >0 if KO * @return int 0 if OK, >0 if KO
*/ */
function list_jobs() public function listJobs()
{ {
// phpcs:enable global $conf, $langs;
global $conf, $db, $langs, $bc;
$error = 0; $error = 0;
$html = ''; $html = '';
@ -489,13 +488,11 @@ class printing_printgcp extends PrintingDriver
$jobs = $responsedata['jobs']; $jobs = $responsedata['jobs'];
//$html .= '<pre>'.print_r($jobs['0'],true).'</pre>'; //$html .= '<pre>'.print_r($jobs['0'],true).'</pre>';
if (is_array($jobs)) if (is_array($jobs)) {
{ foreach ($jobs as $value) {
foreach ($jobs as $value)
{
$html .= '<tr class="oddeven">'; $html .= '<tr class="oddeven">';
$html .= '<td>'.$value['id'].'</td>'; $html .= '<td>'.$value['id'].'</td>';
$dates=dol_print_date((int) substr($value['createTime'], 0, 10), 'dayhour'); $dates = dol_print_date((int) substr($value['createTime'], 0, 10), 'dayhour');
$html .= '<td>'.$dates.'</td>'; $html .= '<td>'.$dates.'</td>';
$html .= '<td>'.$value['ownerId'].'</td>'; $html .= '<td>'.$value['ownerId'].'</td>';
$html .= '<td>'.$value['printerName'].'</td>'; $html .= '<td>'.$value['printerName'].'</td>';

View File

@ -30,16 +30,16 @@ include_once DOL_DOCUMENT_ROOT.'/core/modules/printing/modules_printing.php';
*/ */
class printing_printipp extends PrintingDriver class printing_printipp extends PrintingDriver
{ {
var $name='printipp'; public $name = 'printipp';
var $desc='PrintIPPDesc'; public $desc = 'PrintIPPDesc';
var $picto='printer'; public $picto = 'printer';
var $active='PRINTING_PRINTIPP'; public $active = 'PRINTING_PRINTIPP';
var $conf=array(); public $conf = array();
var $host; public $host;
var $port; public $port;
var $userid; /* user login */ public $userid; /* user login */
var $user; public $user;
var $password; public $password;
/** /**
* @var string Error code (or message) * @var string Error code (or message)
@ -78,7 +78,6 @@ class printing_printipp extends PrintingDriver
$this->conf[] = array('enabled'=>1, 'type'=>'submit'); $this->conf[] = array('enabled'=>1, 'type'=>'submit');
} }
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/** /**
* Print selected file * Print selected file
* *
@ -88,9 +87,8 @@ class printing_printipp extends PrintingDriver
* *
* @return int 0 if OK, >0 if KO * @return int 0 if OK, >0 if KO
*/ */
function print_file($file, $module, $subdir='') public function printFile($file, $module, $subdir='')
{ {
// phpcs:enable
global $conf, $user; global $conf, $user;
$error = 0; $error = 0;
@ -107,8 +105,7 @@ class printing_printipp extends PrintingDriver
// select printer uri for module order, propal,... // select printer uri for module order, propal,...
$sql = "SELECT rowid,printer_id,copy FROM ".MAIN_DB_PREFIX."printing WHERE module = '".$module."' AND driver = 'printipp' AND userid = ".$user->id; $sql = "SELECT rowid,printer_id,copy FROM ".MAIN_DB_PREFIX."printing WHERE module = '".$module."' AND driver = 'printipp' AND userid = ".$user->id;
$result = $this->db->query($sql); $result = $this->db->query($sql);
if ($result) if ($result) {
{
$obj = $this->db->fetch_object($result); $obj = $this->db->fetch_object($result);
if ($obj) if ($obj)
{ {
@ -129,8 +126,9 @@ class printing_printipp extends PrintingDriver
return $error; return $error;
} }
} }
} else {
dol_print_error($this->db);
} }
else dol_print_error($this->db);
// Set number of copy // Set number of copy
$ipp->setCopies($obj->copy); $ipp->setCopies($obj->copy);
@ -156,7 +154,7 @@ class printing_printipp extends PrintingDriver
*/ */
function listAvailablePrinters() function listAvailablePrinters()
{ {
global $bc, $conf, $langs; global $conf, $langs;
$error = 0; $error = 0;
$html = '<tr class="liste_titre">'; $html = '<tr class="liste_titre">';
@ -172,11 +170,9 @@ class printing_printipp extends PrintingDriver
$html.= '<td>'.$langs->trans('IPP_Supported').'</td>'; $html.= '<td>'.$langs->trans('IPP_Supported').'</td>';
$html.= '<td align="center">'.$langs->trans("Select").'</td>'; $html.= '<td align="center">'.$langs->trans("Select").'</td>';
$html.= "</tr>\n"; $html.= "</tr>\n";
$list = $this->getlist_available_printers(); $list = $this->getlistAvailablePrinters();
foreach ($list as $value) foreach ($list as $value) {
{ $printer_det = $this->getPrinterDetail($value);
$printer_det = $this->get_printer_detail($value);
$html.= '<tr class="oddeven">'; $html.= '<tr class="oddeven">';
$html.= '<td>'.$value.'</td>'; $html.= '<td>'.$value.'</td>';
//$html.= '<td><pre>'.print_r($printer_det,true).'</pre></td>'; //$html.= '<td><pre>'.print_r($printer_det,true).'</pre></td>';
@ -191,12 +187,9 @@ class printing_printipp extends PrintingDriver
$html.= '<td>'.$langs->trans('MEDIA_IPP_'.$printer_det->media_type_supported->_value1).'</td>'; $html.= '<td>'.$langs->trans('MEDIA_IPP_'.$printer_det->media_type_supported->_value1).'</td>';
// Defaut // Defaut
$html.= '<td align="center">'; $html.= '<td align="center">';
if ($conf->global->PRINTIPP_URI_DEFAULT == $value) if ($conf->global->PRINTIPP_URI_DEFAULT == $value) {
{
$html.= img_picto($langs->trans("Default"),'on'); $html.= img_picto($langs->trans("Default"),'on');
} } else {
else
{
$html.= '<a href="'.$_SERVER["PHP_SELF"].'?action=setvalue&amp;mode=test&amp;varname=PRINTIPP_URI_DEFAULT&amp;driver=printipp&amp;value='.urlencode($value).'" alt="'.$langs->trans("Default").'">'.img_picto($langs->trans("Disabled"),'off').'</a>'; $html.= '<a href="'.$_SERVER["PHP_SELF"].'?action=setvalue&amp;mode=test&amp;varname=PRINTIPP_URI_DEFAULT&amp;driver=printipp&amp;value='.urlencode($value).'" alt="'.$langs->trans("Default").'">'.img_picto($langs->trans("Disabled"),'off').'</a>';
} }
$html.= '</td>'; $html.= '</td>';
@ -206,37 +199,35 @@ class printing_printipp extends PrintingDriver
return $error; return $error;
} }
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/** /**
* Return list of available printers * Return list of available printers
* *
* @return array list of printers * @return array list of printers
*/ */
function getlist_available_printers() public function getlistAvailablePrinters()
{ {
// phpcs:enable global $conf, $db;
global $conf,$db;
include_once DOL_DOCUMENT_ROOT.'/includes/printipp/CupsPrintIPP.php'; include_once DOL_DOCUMENT_ROOT.'/includes/printipp/CupsPrintIPP.php';
$ipp = new CupsPrintIPP(); $ipp = new CupsPrintIPP();
$ipp->setLog(DOL_DATA_ROOT.'/dolibarr_printipp.log','file',3); // logging very verbose $ipp->setLog(DOL_DATA_ROOT.'/dolibarr_printipp.log','file',3); // logging very verbose
$ipp->setHost($this->host); $ipp->setHost($this->host);
$ipp->setPort($this->port); $ipp->setPort($this->port);
$ipp->setUserName($this->userid); $ipp->setUserName($this->userid);
if (! empty($this->user)) $ipp->setAuthentication($this->user,$this->password); if (! empty($this->user)) {
$ipp->setAuthentication($this->user, $this->password);
}
$ipp->getPrinters(); $ipp->getPrinters();
return $ipp->available_printers; return $ipp->available_printers;
} }
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/** /**
* Get printer detail * Get printer detail
* *
* @param string $uri URI * @param string $uri URI
* @return array List of attributes * @return array List of attributes
*/ */
function get_printer_detail($uri) private function getPrinterDetail($uri)
{ {
// phpcs:enable
global $conf,$db; global $conf,$db;
include_once DOL_DOCUMENT_ROOT.'/includes/printipp/CupsPrintIPP.php'; include_once DOL_DOCUMENT_ROOT.'/includes/printipp/CupsPrintIPP.php';
@ -245,13 +236,14 @@ class printing_printipp extends PrintingDriver
$ipp->setHost($this->host); $ipp->setHost($this->host);
$ipp->setPort($this->port); $ipp->setPort($this->port);
$ipp->setUserName($this->userid); $ipp->setUserName($this->userid);
if (! empty($this->user)) $ipp->setAuthentication($this->user,$this->password); if (! empty($this->user)) {
$ipp->setAuthentication($this->user, $this->password);
}
$ipp->setPrinterURI($uri); $ipp->setPrinterURI($uri);
$ipp->getPrinterAttributes(); $ipp->getPrinterAttributes();
return $ipp->printer_attributes; return $ipp->printer_attributes;
} }
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/** /**
* List jobs print * List jobs print
* *
@ -259,10 +251,9 @@ class printing_printipp extends PrintingDriver
* *
* @return int 0 if OK, >0 if KO * @return int 0 if OK, >0 if KO
*/ */
function list_jobs($module) public function listJobs($module)
{ {
// phpcs:enable global $conf;
global $conf, $db, $bc;
$error = 0; $error = 0;
$html = ''; $html = '';
include_once DOL_DOCUMENT_ROOT.'/includes/printipp/CupsPrintIPP.php'; include_once DOL_DOCUMENT_ROOT.'/includes/printipp/CupsPrintIPP.php';
@ -271,19 +262,17 @@ class printing_printipp extends PrintingDriver
$ipp->setHost($this->host); $ipp->setHost($this->host);
$ipp->setPort($this->port); $ipp->setPort($this->port);
$ipp->setUserName($this->userid); $ipp->setUserName($this->userid);
if (! empty($this->user)) $ipp->setAuthentication($this->user,$this->password); if (! empty($this->user)) {
$ipp->setAuthentication($this->user,$this->password);
}
// select printer uri for module order, propal,... // select printer uri for module order, propal,...
$sql = 'SELECT rowid,printer_uri,printer_name FROM '.MAIN_DB_PREFIX.'printer_ipp WHERE module="'.$module.'"'; $sql = 'SELECT rowid,printer_uri,printer_name FROM '.MAIN_DB_PREFIX.'printer_ipp WHERE module="'.$module.'"';
$result = $this->db->query($sql); $result = $this->db->query($sql);
if ($result) if ($result) {
{
$obj = $this->db->fetch_object($result); $obj = $this->db->fetch_object($result);
if ($obj) if ($obj) {
{
$ipp->setPrinterURI($obj->printer_uri); $ipp->setPrinterURI($obj->printer_uri);
} } else {
else
{
// All printers // All printers
$ipp->setPrinterURI("ipp://localhost:631/printers/"); $ipp->setPrinterURI("ipp://localhost:631/printers/");
} }
@ -307,8 +296,7 @@ class printing_printipp extends PrintingDriver
$jobs = $ipp->jobs_attributes; $jobs = $ipp->jobs_attributes;
//$html .= '<pre>'.print_r($jobs,true).'</pre>'; //$html .= '<pre>'.print_r($jobs,true).'</pre>';
foreach ($jobs as $value ) foreach ($jobs as $value ) {
{
$html .= '<tr class="oddeven">'; $html .= '<tr class="oddeven">';
$html .= '<td>'.$value->job_id->_value0.'</td>'; $html .= '<td>'.$value->job_id->_value0.'</td>';
$html .= '<td>'.$value->job_originating_user_name->_value0.'</td>'; $html .= '<td>'.$value->job_originating_user_name->_value0.'</td>';

View File

@ -109,12 +109,12 @@ if ($action == 'setvalue' && $user->admin)
$form = new Form($db); $form = new Form($db);
llxHeader('',$langs->trans("PrintingSetup")); llxHeader('', $langs->trans("PrintingSetup"));
$linkback='<a href="'.DOL_URL_ROOT.'/admin/modules.php?restore_lastsearch_values=1">'.$langs->trans("BackToModuleList").'</a>'; $linkback='<a href="'.DOL_URL_ROOT.'/admin/modules.php?restore_lastsearch_values=1">'.$langs->trans("BackToModuleList").'</a>';
print load_fiche_titre($langs->trans("PrintingSetup"),$linkback,'title_setup'); print load_fiche_titre($langs->trans("PrintingSetup"),$linkback,'title_setup');
$head=printingadmin_prepare_head($mode); $head = printingAdminPrepareHead($mode);
if ($mode == 'setup' && $user->admin) if ($mode == 'setup' && $user->admin)
{ {
@ -134,8 +134,7 @@ if ($mode == 'setup' && $user->admin)
print "</tr>\n"; print "</tr>\n";
$submit_enabled=0; $submit_enabled=0;
if (! empty($driver)) if (! empty($driver)) {
{
require_once DOL_DOCUMENT_ROOT.'/core/modules/printing/'.$driver.'.modules.php'; require_once DOL_DOCUMENT_ROOT.'/core/modules/printing/'.$driver.'.modules.php';
$classname = 'printing_'.$driver; $classname = 'printing_'.$driver;
$langs->load($driver); $langs->load($driver);
@ -304,7 +303,7 @@ if ($mode == 'test' && $user->admin)
$langs->load($driver); $langs->load($driver);
$printer = new $classname($db); $printer = new $classname($db);
//print '<pre>'.print_r($printer, true).'</pre>'; //print '<pre>'.print_r($printer, true).'</pre>';
if (count($printer->getlist_available_printers())) { if (count($printer->getlistAvailablePrinters())) {
if ($printer->listAvailablePrinters()==0) { if ($printer->listAvailablePrinters()==0) {
print $printer->resprint; print $printer->resprint;
} else { } else {

View File

@ -1,5 +1,5 @@
<?php <?php
/* Copyright (C) 2014-2015 Frederic France <frederic.france@free.fr> /* Copyright (C) 2014-2018 Frederic France <frederic.france@netlogic.fr>
* Copyright (C) 2016 Laurent Destailleur <eldy@users.sourceforge.net> * Copyright (C) 2016 Laurent Destailleur <eldy@users.sourceforge.net>
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
@ -40,29 +40,26 @@ $langs->load("printing");
* View * View
*/ */
llxHeader("",$langs->trans("Printing")); llxHeader("", $langs->trans("Printing"));
print_barre_liste($langs->trans("Printing"), 0, $_SERVER["PHP_SELF"], '', '', '', '<a class="button" href="'.$_SERVER["PHP_SELF"].'">'.$langs->trans("Refresh").'</a>', 0, 0, 'title_setup.png'); print_barre_liste($langs->trans("Printing"), 0, $_SERVER["PHP_SELF"], '', '', '', '<a class="button" href="' . $_SERVER["PHP_SELF"] . '">' . $langs->trans("Refresh") . '</a>', 0, 0, 'title_setup.png');
print $langs->trans("DirectPrintingJobsDesc").'<br><br>'; print $langs->trans("DirectPrintingJobsDesc").'<br><br>';
// List Jobs from printing modules // List Jobs from printing modules
$object = new PrintingDriver($db); $object = new PrintingDriver($db);
$result = $object->listDrivers($db, 10); $result = $object->listDrivers($db, 10);
foreach ($result as $driver) foreach ($result as $driver) {
{
require_once DOL_DOCUMENT_ROOT.'/core/modules/printing/'.$driver.'.modules.php'; require_once DOL_DOCUMENT_ROOT.'/core/modules/printing/'.$driver.'.modules.php';
$classname = 'printing_'.$driver; $classname = 'printing_'.$driver;
$langs->load($driver); $langs->load($driver);
$printer = new $classname($db); $printer = new $classname($db);
if ($conf->global->{$printer->active}) if ($conf->global->{$printer->active}) {
{ //$printer->listJobs('commande');
//$printer->list_jobs('commande'); $result = $printer->listJobs();
$result = $printer->list_jobs();
print $printer->resprint; print $printer->resprint;
if ($result > 0) if ($result > 0) {
{
setEventMessages($printer->error, $printer->errors, 'errors'); setEventMessages($printer->error, $printer->errors, 'errors');
} }
} }

View File

@ -1,5 +1,6 @@
<?php <?php
/* Copyright (C) 2015 Laurent Destailleur <eldy@users.sourceforge.net> /* Copyright (C) 2015 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2018 Frédéric France <frederic.france@netlogic.fr>
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
@ -27,9 +28,9 @@
* Define head array for tabs of printing tools setup pages * Define head array for tabs of printing tools setup pages
* *
* @param string $mode Mode * @param string $mode Mode
* @return Array of head * @return array Array of head
*/ */
function printingadmin_prepare_head($mode) function printingAdminPrepareHead($mode)
{ {
global $langs, $conf; global $langs, $conf;
@ -41,16 +42,14 @@ function printingadmin_prepare_head($mode)
$head[$h][2] = 'config'; $head[$h][2] = 'config';
$h++; $h++;
if ($mode == 'setup') if ($mode == 'setup') {
{
$head[$h][0] = DOL_URL_ROOT."/printing/admin/printing.php?mode=setup&driver=".GETPOST('driver','alpha'); $head[$h][0] = DOL_URL_ROOT."/printing/admin/printing.php?mode=setup&driver=".GETPOST('driver','alpha');
$head[$h][1] = $langs->trans("SetupDriver"); $head[$h][1] = $langs->trans("SetupDriver");
$head[$h][2] = 'setup'; $head[$h][2] = 'setup';
$h++; $h++;
} }
if ($mode == 'test') if ($mode == 'test') {
{
$head[$h][0] = DOL_URL_ROOT."/printing/admin/printing.php?mode=test&driver=".GETPOST('driver','alpha'); $head[$h][0] = DOL_URL_ROOT."/printing/admin/printing.php?mode=test&driver=".GETPOST('driver','alpha');
$head[$h][1] = $langs->trans("TargetedPrinter"); $head[$h][1] = $langs->trans("TargetedPrinter");
$head[$h][2] = 'test'; $head[$h][2] = 'test';
@ -76,4 +75,3 @@ function printingadmin_prepare_head($mode)
return $head; return $head;
} }