diff --git a/htdocs/commande/fiche.php b/htdocs/commande/fiche.php
index 97bcc12b504..b1520e40681 100644
--- a/htdocs/commande/fiche.php
+++ b/htdocs/commande/fiche.php
@@ -1154,11 +1154,13 @@ else if ($action == 'remove_file')
}
// Print file
-else if ($action == 'print_file' AND $user->rights->printipp->use)
+else if ($action == 'print_file' AND $user->rights->printipp->read)
{
require_once DOL_DOCUMENT_ROOT.'/core/class/dolprintipp.class.php';
$printer = new dolPrintIPP($db,$conf->global->PRINTIPP_HOST,$conf->global->PRINTIPP_PORT,$user->login,$conf->global->PRINTIPP_USER,$conf->global->PRINTIPP_PASSWORD);
$printer->print_file(GETPOST('file','alpha'),GETPOST('printer','alpha'));
+ setEventMessage($langs->trans("FileWasSentToPrinter", GETPOST('file')));
+ $action='';
}
else if ($action == 'update_extras')
@@ -2493,9 +2495,7 @@ else
$urlsource=$_SERVER["PHP_SELF"]."?id=".$object->id;
$genallowed=$user->rights->commande->creer;
$delallowed=$user->rights->commande->supprimer;
- $printer = false;
- if ($user->rights->printipp->use AND $conf->printipp->enabled) $printer = true;
- $somethingshown=$formfile->show_documents('commande',$comref,$filedir,$urlsource,$genallowed,$delallowed,$object->modelpdf,1,0,0,28,0,'','','',$soc->default_lang,$printer);
+ $somethingshown=$formfile->show_documents('commande',$comref,$filedir,$urlsource,$genallowed,$delallowed,$object->modelpdf,1,0,0,28,0,'','','',$soc->default_lang);
/*
* Linked object block
diff --git a/htdocs/compta/facture.php b/htdocs/compta/facture.php
index fce7398f9b5..ae3a8b08a72 100644
--- a/htdocs/compta/facture.php
+++ b/htdocs/compta/facture.php
@@ -100,7 +100,7 @@ $hookmanager->initHooks(array('invoicecard'));
/*
* Actions
-*/
+ */
$parameters=array('socid'=>$socid);
$reshook=$hookmanager->executeHooks('doActions',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks
@@ -1831,6 +1831,16 @@ else if ($action == 'remove_file')
}
}
+// Print file
+else if ($action == 'print_file' AND $user->rights->printipp->read)
+{
+ require_once DOL_DOCUMENT_ROOT.'/core/class/dolprintipp.class.php';
+ $printer = new dolPrintIPP($db,$conf->global->PRINTIPP_HOST,$conf->global->PRINTIPP_PORT,$user->login,$conf->global->PRINTIPP_USER,$conf->global->PRINTIPP_PASSWORD);
+ $printer->print_file(GETPOST('file',alpha),GETPOST('printer',alpha));
+ setEventMessage($langs->trans("FileWasSentToPrinter", GETPOST('file')));
+ $action='';
+}
+
if (! empty($conf->global->MAIN_DISABLE_CONTACTS_TAB) && $user->rights->facture->creer)
{
if ($action == 'addcontact')
diff --git a/htdocs/core/class/dolprintipp.class.php b/htdocs/core/class/dolprintipp.class.php
index e7a0d051cb3..c1add1087e2 100644
--- a/htdocs/core/class/dolprintipp.class.php
+++ b/htdocs/core/class/dolprintipp.class.php
@@ -111,6 +111,7 @@ class dolprintIPP
$ipp->setPrinterURI($conf->global->PRINTIPP_URI_DEFAULT);
}
}
+ // Set number of copy
$ipp->setCopies($obj->copy);
$ipp->setData(DOL_DATA_ROOT.'/'.$module.'/'.$file);
$ipp->printJob();
@@ -148,10 +149,52 @@ class dolprintIPP
$ipp->setPrinterURI("ipp://localhost:631/printers/");
}
}
- echo 'Jobs for : '.$this->userid.' module : '.$module.' Printer : '.$obj->printer_name.'
';
- echo "Getting Jobs: ".$ipp->getJobs(true,3,"completed",true)."
";
+ // Getting Jobs
+ $ipp->getJobs(false,0,'completed',false);
+ print '
';
+ print '';
+ print "| Id | ";
+ print "Owner | ";
+ print "Printer | ";
+ print "File | ";
+ print "Status | ";
+ print "Cancel | ";
+ print "
\n";
+ $jobs = $ipp->jobs_attributes;
+ $var = True;
+ //print ''.print_r($jobs,true).'
';
+ foreach ($jobs as $value )
+ {
+ $var=!$var;
+ print "";
+ print '| '.$value->job_id->_value0.' | ';
+ print ''.$value->job_originating_user_name->_value0.' | ';
+ print ''.$value->printer_uri->_value0.' | ';
+ print ''.$value->job_name->_value0.' | ';
+ print ''.$value->job_state->_value0.' | ';
+ print ''.$value->job_uri->_value0.' | ';
+ print '
';
+ }
+ print "
";
+ }
- echo "";print_r($ipp->jobs_attributes); echo "
";
+ /**
+ * Get printer detail
+ *
+ */
+ 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);
+ $ipp->setPrinterURI($uri);
+ $ipp->getPrinterAttributes();
+ return $ipp->printer_attributes;
}
}
?>
diff --git a/htdocs/core/class/html.formfile.class.php b/htdocs/core/class/html.formfile.class.php
index f8f2503c9a7..0e30d1ebb9f 100644
--- a/htdocs/core/class/html.formfile.class.php
+++ b/htdocs/core/class/html.formfile.class.php
@@ -163,13 +163,12 @@ class FormFile
* @param string $title Title to show on top of form
* @param string $buttonlabel Label on submit button
* @param string $codelang Default language code to use on lang combo box if multilang is enabled
- * @param boolean $printer Printer Icon
* @return int <0 if KO, number of shown files if OK
*/
- function show_documents($modulepart,$filename,$filedir,$urlsource,$genallowed,$delallowed=0,$modelselected='',$allowgenifempty=1,$forcenomultilang=0,$iconPDF=0,$maxfilenamelength=28,$noform=0,$param='',$title='',$buttonlabel='',$codelang='',$printer=false)
+ function show_documents($modulepart,$filename,$filedir,$urlsource,$genallowed,$delallowed=0,$modelselected='',$allowgenifempty=1,$forcenomultilang=0,$iconPDF=0,$maxfilenamelength=28,$noform=0,$param='',$title='',$buttonlabel='',$codelang='')
{
$this->numoffiles=0;
- print $this->showdocuments($modulepart,$filename,$filedir,$urlsource,$genallowed,$delallowed,$modelselected,$allowgenifempty,$forcenomultilang,$iconPDF,$maxfilenamelength,$noform,$param,$title,$buttonlabel,$codelang,$printer);
+ print $this->showdocuments($modulepart,$filename,$filedir,$urlsource,$genallowed,$delallowed,$modelselected,$allowgenifempty,$forcenomultilang,$iconPDF,$maxfilenamelength,$noform,$param,$title,$buttonlabel,$codelang);
return $this->numoffiles;
}
@@ -193,22 +192,22 @@ class FormFile
* @param string $title Title to show on top of form
* @param string $buttonlabel Label on submit button
* @param string $codelang Default language code to use on lang combo box if multilang is enabled
- * @param boolean $printer Printer Icon
* @return string Output string with HTML array of documents (might be empty string)
*/
- function showdocuments($modulepart,$filename,$filedir,$urlsource,$genallowed,$delallowed=0,$modelselected='',$allowgenifempty=1,$forcenomultilang=0,$iconPDF=0,$maxfilenamelength=28,$noform=0,$param='',$title='',$buttonlabel='',$codelang='',$printer=false)
+ function showdocuments($modulepart,$filename,$filedir,$urlsource,$genallowed,$delallowed=0,$modelselected='',$allowgenifempty=1,$forcenomultilang=0,$iconPDF=0,$maxfilenamelength=28,$noform=0,$param='',$title='',$buttonlabel='',$codelang='')
{
- // filedir = conf->...dir_ouput."/".get_exdir(id)
- include_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
-
global $langs,$conf,$hookmanager;
global $bc;
+ // filedir = $conf->...->dir_ouput."/".get_exdir(id)
+ include_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
+
// For backward compatibility
if (! empty($iconPDF)) {
return $this->getDocumentsLink($modulepart, $filename, $filedir);
}
-
+ $printer = ($user->rights->printipp->read && $conf->printipp->enabled)?true:false;
+
$forname='builddoc';
$out='';
$var=true;
diff --git a/htdocs/core/modules/modPrintIPP.class.php b/htdocs/core/modules/modPrintIPP.class.php
index 35fd62af04e..d91b066963b 100644
--- a/htdocs/core/modules/modPrintIPP.class.php
+++ b/htdocs/core/modules/modPrintIPP.class.php
@@ -97,7 +97,7 @@ class modPrintIPP extends DolibarrModules
$this->rights[$r][1] = 'Printer';
$this->rights[$r][2] = 'r';
$this->rights[$r][3] = 1;
- $this->rights[$r][4] = 'use';
+ $this->rights[$r][4] = 'read';
// Main menu entries
$this->menus = array(); // List of menus to add
@@ -112,7 +112,7 @@ class modPrintIPP extends DolibarrModules
'langs'=>'printipp', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory.
'position'=>100,
'enabled'=>'$conf->printipp->enabled',
- 'perms'=>'$user->rights->printipp->use', // Use 'perms'=>'1' if you want your menu with no permission rules
+ 'perms'=>'$user->rights->printipp->read', // Use 'perms'=>'1' if you want your menu with no permission rules
'target'=>'',
'user'=>0); // 0=Menu for internal users, 1=external users, 2=both
diff --git a/htdocs/printipp/admin/printipp.php b/htdocs/printipp/admin/printipp.php
index 34163f125ec..6ea4e1dd2f9 100644
--- a/htdocs/printipp/admin/printipp.php
+++ b/htdocs/printipp/admin/printipp.php
@@ -44,6 +44,12 @@ if (!$mode) $mode='config';
if ($action == 'setvalue' && $user->admin)
{
$db->begin();
+ if (GETPOST('PRINTIPP_ENABLED','alpha') == '1') $result=dolibarr_set_const($db, "PRINTIPP_ENABLED",1,'yesno',0,'',$conf->entity);
+ else
+ {
+ $result=dolibarr_del_const($db, "PRINTIPP_ENABLED",$conf->entity);
+ }
+ if (! $result > 0) $error++;
$result=dolibarr_set_const($db, "PRINTIPP_HOST",GETPOST('PRINTIPP_HOST','alpha'),'chaine',0,'',$conf->entity);
if (! $result > 0) $error++;
$result=dolibarr_set_const($db, "PRINTIPP_PORT",GETPOST('PRINTIPP_PORT','alpha'),'chaine',0,'',$conf->entity);
@@ -101,6 +107,27 @@ if ($mode=='config'&& $user->admin)
print ''.$langs->trans("Value").' | ';
print "\n";
+ $var=!$var;
+ print '| ';
+ print $langs->trans("PRINTIPP_ENABLED").' | ';
+
+ if (! empty($conf->use_javascript_ajax))
+ {
+ print ajax_constantonoff('PRINTIPP_ENABLED');
+ }
+ else
+ {
+ if (empty($conf->global->PRINTIPP_ENABLED))
+ {
+ print ''.img_picto($langs->trans("Disabled"),'off').'';
+ }
+ else
+ {
+ print ''.img_picto($langs->trans("Enabled"),'on').'';
+ }
+ }
+ print ' |
';
+
$var=!$var;
print '| ';
print $langs->trans("PRINTIPP_HOST").' | ';
@@ -145,10 +172,39 @@ if ($mode=='test'&& $user->admin)
print '';
$printer = new dolPrintIPP($db,$conf->global->PRINTIPP_HOST,$conf->global->PRINTIPP_PORT,$user->login,$conf->global->PRINTIPP_USER,$conf->global->PRINTIPP_PASSWORD);
$var=true;
+ print '';
print '';
- print '| '.$langs->trans("TestConnect").' | ';
- print print_r($printer->getlist_available_printers(),true);
+ print 'Uri | ';
+ print 'Name | ';
+ print 'State | ';
+ print 'State_reason | ';
+ print 'State_reason1 | ';
+ print 'BW | ';
+ print 'Color | ';
+ //print 'Device | ';
+ print 'Media | ';
+ print 'Supported | ';
print " \n";
+ $list = $printer->getlist_available_printers();
+ $var = True;
+ foreach ($list as $value )
+ {
+ $var=!$var;
+ $printer_det = $printer->get_printer_detail($value);
+ print "";
+ print '| '.$value.' | ';
+ //print ''.print_r($printer_det,true).' | ';
+ print ''.$printer_det->printer_name->_value0.' | ';
+ print ''.$printer_det->printer_state->_value0.' | ';
+ print ''.$printer_det->printer_state_reasons->_value0.' | ';
+ print ''.$printer_det->printer_state_reasons->_value1.' | ';
+ print ''.$printer_det->printer_type->_value2.' | ';
+ print ''.$printer_det->printer_type->_value3.' | ';
+ //print ''.$printer_det->device_uri->_value0.' | ';
+ print ''.$printer_det->media_default->_value0.' | ';
+ print ''.$printer_det->media_type_supported->_value1.' | ';
+ print " \n";
+ }
print ' ';
}
|