frederic34-develop

Conflicts:
	htdocs/commande/fiche.php
	htdocs/compta/facture.php
This commit is contained in:
Laurent Destailleur 2013-06-12 10:47:56 +02:00
commit 0c9bc2ac5f
6 changed files with 129 additions and 21 deletions

View File

@ -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

View File

@ -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')

View File

@ -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.'<br />';
echo "Getting Jobs: ".$ipp->getJobs(true,3,"completed",true)."<br />";
// Getting Jobs
$ipp->getJobs(false,0,'completed',false);
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>';
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>";
}
echo "<pre>";print_r($ipp->jobs_attributes); echo "</pre>";
/**
* 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;
}
}
?>

View File

@ -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;

View File

@ -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

View File

@ -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 '<td>'.$langs->trans("Value").'</td>';
print "</tr>\n";
$var=!$var;
print '<tr '.$bc[$var].'><td class="fieldrequired">';
print $langs->trans("PRINTIPP_ENABLED").'</td><td colspan="2" align="left">';
if (! empty($conf->use_javascript_ajax))
{
print ajax_constantonoff('PRINTIPP_ENABLED');
}
else
{
if (empty($conf->global->PRINTIPP_ENABLED))
{
print '<a href="'.$_SERVER['PHP_SELF'].'?action=set_PRINTIPP_ENABLED">'.img_picto($langs->trans("Disabled"),'off').'</a>';
}
else
{
print '<a href="'.$_SERVER['PHP_SELF'].'?action=del_PRINTIPP_ENABLED">'.img_picto($langs->trans("Enabled"),'on').'</a>';
}
}
print '</td></tr>';
$var=!$var;
print '<tr '.$bc[$var].'><td class="fieldrequired">';
print $langs->trans("PRINTIPP_HOST").'</td><td>';
@ -145,10 +172,39 @@ if ($mode=='test'&& $user->admin)
print '<table class="nobordernopadding" width="100%">';
$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 '<table width="100%" class="noborder">';
print '<tr class="liste_titre">';
print '<td>'.$langs->trans("TestConnect").'</td>';
print print_r($printer->getlist_available_printers(),true);
print '<td>Uri</td>';
print '<td>Name</td>';
print '<td>State</td>';
print '<td>State_reason</td>';
print '<td>State_reason1</td>';
print '<td>BW</td>';
print '<td>Color</td>';
//print '<td>Device</td>';
print '<td>Media</td>';
print '<td>Supported</td>';
print "</tr>\n";
$list = $printer->getlist_available_printers();
$var = True;
foreach ($list as $value )
{
$var=!$var;
$printer_det = $printer->get_printer_detail($value);
print "<tr $bc[$var]>";
print '<td>'.$value.'</td>';
//print '<td><pre>'.print_r($printer_det,true).'</pre></td>';
print '<td>'.$printer_det->printer_name->_value0.'</td>';
print '<td>'.$printer_det->printer_state->_value0.'</td>';
print '<td>'.$printer_det->printer_state_reasons->_value0.'</td>';
print '<td>'.$printer_det->printer_state_reasons->_value1.'</td>';
print '<td>'.$printer_det->printer_type->_value2.'</td>';
print '<td>'.$printer_det->printer_type->_value3.'</td>';
//print '<td>'.$printer_det->device_uri->_value0.'</td>';
print '<td>'.$printer_det->media_default->_value0.'</td>';
print '<td>'.$printer_det->media_type_supported->_value1.'</td>';
print "</tr>\n";
}
print '</table>';
}