Clean module print system
This commit is contained in:
parent
d5ec19ef83
commit
8a6d3aa633
@ -50,7 +50,8 @@ class modPrinting extends DolibarrModules
|
|||||||
$this->family = "other";
|
$this->family = "other";
|
||||||
// Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module)
|
// Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module)
|
||||||
$this->name = preg_replace('/^mod/i','',get_class($this));
|
$this->name = preg_replace('/^mod/i','',get_class($this));
|
||||||
$this->description = "Enable Printing System.";
|
// Module description, used if translation string 'ModuleXXXDesc' not found (where XXX is value of numeric property 'numero' of module)
|
||||||
|
$this->description = "Enable Direct Printing System.";
|
||||||
$this->version = 'dolibarr'; // 'development' or 'experimental' or 'dolibarr' or version
|
$this->version = 'dolibarr'; // 'development' or 'experimental' or 'dolibarr' or version
|
||||||
$this->const_name = 'MAIN_MODULE_'.strtoupper($this->name);
|
$this->const_name = 'MAIN_MODULE_'.strtoupper($this->name);
|
||||||
// Where to store the module in setup page (0=common,1=interface,2=others,3=very specific)
|
// Where to store the module in setup page (0=common,1=interface,2=others,3=very specific)
|
||||||
|
|||||||
@ -26,8 +26,7 @@
|
|||||||
include_once DOL_DOCUMENT_ROOT.'/core/modules/printing/modules_printing.php';
|
include_once DOL_DOCUMENT_ROOT.'/core/modules/printing/modules_printing.php';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \class mailing_example
|
* Class to provide printing with Google Cloud Print
|
||||||
* \brief Class to provide printing with Google Cloud Print
|
|
||||||
*/
|
*/
|
||||||
class printing_printgcp extends PrintingDriver
|
class printing_printgcp extends PrintingDriver
|
||||||
{
|
{
|
||||||
@ -175,7 +174,7 @@ class printing_printgcp extends PrintingDriver
|
|||||||
if ($subdir!='') $fileprint.='/'.$subdir;
|
if ($subdir!='') $fileprint.='/'.$subdir;
|
||||||
$fileprint.='/'.$file;
|
$fileprint.='/'.$file;
|
||||||
// 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="printgcp" AND userid='.$user->id;
|
$sql = "SELECT rowid, printer_id, copy FROM ".MAIN_DB_PREFIX."printing WHERE module='".$module."' AND driver='printgcp' AND userid=".$user->id;
|
||||||
$result = $db->query($sql);
|
$result = $db->query($sql);
|
||||||
if ($result)
|
if ($result)
|
||||||
{
|
{
|
||||||
@ -196,6 +195,7 @@ class printing_printgcp extends PrintingDriver
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else dol_print_error($db);
|
||||||
|
|
||||||
$this->sendPrintToPrinter($printer_id, $file, $fileprint, 'application/pdf');
|
$this->sendPrintToPrinter($printer_id, $file, $fileprint, 'application/pdf');
|
||||||
}
|
}
|
||||||
|
|||||||
@ -26,8 +26,7 @@
|
|||||||
include_once DOL_DOCUMENT_ROOT.'/core/modules/printing/modules_printing.php';
|
include_once DOL_DOCUMENT_ROOT.'/core/modules/printing/modules_printing.php';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \class mailing_example
|
* Class to provide printing with PrintIPP
|
||||||
* \brief Class to provide printing with PrintIPP
|
|
||||||
*/
|
*/
|
||||||
class printing_printipp extends PrintingDriver
|
class printing_printipp extends PrintingDriver
|
||||||
{
|
{
|
||||||
@ -61,8 +60,8 @@ class printing_printipp extends PrintingDriver
|
|||||||
$this->password=$conf->global->PRINTIPP_PASSWORD;
|
$this->password=$conf->global->PRINTIPP_PASSWORD;
|
||||||
$this->conf[] = array('varname'=>'PRINTIPP_HOST', 'required'=>1, 'example'=>'localhost', 'type'=>'text');
|
$this->conf[] = array('varname'=>'PRINTIPP_HOST', 'required'=>1, 'example'=>'localhost', 'type'=>'text');
|
||||||
$this->conf[] = array('varname'=>'PRINTIPP_PORT', 'required'=>1, 'example'=>'631', 'type'=>'text');
|
$this->conf[] = array('varname'=>'PRINTIPP_PORT', 'required'=>1, 'example'=>'631', 'type'=>'text');
|
||||||
$this->conf[] = array('varname'=>'PRINTIPP_USER', 'required'=>0, 'example'=>'', 'type'=>'text');
|
$this->conf[] = array('varname'=>'PRINTIPP_USER', 'required'=>0, 'example'=>'', 'type'=>'text', 'moreattributes'=>'autocomplete="off"');
|
||||||
$this->conf[] = array('varname'=>'PRINTIPP_PASSWORD', 'required'=>0, 'example'=>'', 'type'=>'password');
|
$this->conf[] = array('varname'=>'PRINTIPP_PASSWORD', 'required'=>0, 'example'=>'', 'type'=>'password', 'moreattributes'=>'autocomplete="off"');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -89,27 +88,30 @@ class printing_printipp extends PrintingDriver
|
|||||||
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_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 = $db->query($sql);
|
$result = $db->query($sql);
|
||||||
if ($result)
|
if ($result)
|
||||||
{
|
{
|
||||||
$obj = $this->db->fetch_object($result);
|
$obj = $this->db->fetch_object($result);
|
||||||
if ($obj)
|
if ($obj)
|
||||||
{
|
{
|
||||||
|
dol_syslog("Found a default printer for user ".$user->id." = ".$obj->printer_id);
|
||||||
$ipp->setPrinterURI($obj->printer_id);
|
$ipp->setPrinterURI($obj->printer_id);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (! empty($conf->global->PRINTIPP_URI_DEFAULT))
|
if (! empty($conf->global->PRINTIPP_URI_DEFAULT))
|
||||||
{
|
{
|
||||||
|
dol_syslog("Will use default printer conf->global->PRINTIPP_URI_DEFAULT = ".$conf->global->PRINTIPP_URI_DEFAULT);
|
||||||
$ipp->setPrinterURI($conf->global->PRINTIPP_URI_DEFAULT);
|
$ipp->setPrinterURI($conf->global->PRINTIPP_URI_DEFAULT);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
return 'NoDefaultPrinterDefined';
|
return 'NoDefaultPrinterDefined';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else dol_print_error($db);
|
||||||
|
|
||||||
// Set number of copy
|
// Set number of copy
|
||||||
$ipp->setCopies($obj->copy);
|
$ipp->setCopies($obj->copy);
|
||||||
@ -170,8 +172,10 @@ class printing_printipp extends PrintingDriver
|
|||||||
$html.= img_picto($langs->trans("Default"),'on');
|
$html.= img_picto($langs->trans("Default"),'on');
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
$html.= '<a href="'.$_SERVER["PHP_SELF"].'?action=setvalue&mode=test&varname=PRINTIPP_URI_DEFAULT&driver=printipp&value='.urlencode($value).'" alt="'.$langs->trans("Default").'">'.img_picto($langs->trans("Disabled"),'off').'</a>';
|
{
|
||||||
$html.= '</td>';
|
$html.= '<a href="'.$_SERVER["PHP_SELF"].'?action=setvalue&mode=test&varname=PRINTIPP_URI_DEFAULT&driver=printipp&value='.urlencode($value).'" alt="'.$langs->trans("Default").'">'.img_picto($langs->trans("Disabled"),'off').'</a>';
|
||||||
|
}
|
||||||
|
$html.= '</td>';
|
||||||
$html.= '</tr>'."\n";
|
$html.= '</tr>'."\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
# Dolibarr language file - Source file is en_US - printing
|
# Dolibarr language file - Source file is en_US - printing
|
||||||
PrintingSetup=Setup of Printing System
|
PrintingSetup=Setup of Direct Printing System
|
||||||
PrintingDesc=This module adds a Print button to send documents directly to a printer with various module.
|
PrintingDesc=This module adds a Print button to send documents directly to a printer (without opening document into an application) with various module.
|
||||||
ModuleDriverSetup=Setup Module Driver
|
ModuleDriverSetup=Setup Module Driver
|
||||||
PrintingDriverDesc=Configuration variables for printing driver.
|
PrintingDriverDesc=Configuration variables for printing driver.
|
||||||
ListDrivers=List of drivers
|
ListDrivers=List of drivers
|
||||||
@ -8,3 +8,9 @@ PrintTestDesc=List of Printers.
|
|||||||
FileWasSentToPrinter=File %s was sent to printer
|
FileWasSentToPrinter=File %s was sent to printer
|
||||||
NoActivePrintingModuleFound=No active module to print document
|
NoActivePrintingModuleFound=No active module to print document
|
||||||
PleaseSelectaDriverfromList=Please select a driver from list.
|
PleaseSelectaDriverfromList=Please select a driver from list.
|
||||||
|
SetupDriver=Driver setup
|
||||||
|
TestDriver=Test
|
||||||
|
TargetedPrinter=Targeted printer
|
||||||
|
UserConf=Setup per user
|
||||||
|
Module112000Name=Direct Printing
|
||||||
|
Module112000Desc=Enable Direct Printing System
|
||||||
|
|||||||
@ -109,15 +109,15 @@ llxHeader('',$langs->trans("PrintingSetup"));
|
|||||||
$linkback='<a href="'.DOL_URL_ROOT.'/admin/modules.php">'.$langs->trans("BackToModuleList").'</a>';
|
$linkback='<a href="'.DOL_URL_ROOT.'/admin/modules.php">'.$langs->trans("BackToModuleList").'</a>';
|
||||||
print_fiche_titre($langs->trans("PrintingSetup"),$linkback,'setup');
|
print_fiche_titre($langs->trans("PrintingSetup"),$linkback,'setup');
|
||||||
|
|
||||||
$head=printingadmin_prepare_head();
|
$head=printingadmin_prepare_head($mode);
|
||||||
|
|
||||||
if ($mode == 'setup' && $user->admin)
|
if ($mode == 'setup' && $user->admin)
|
||||||
{
|
{
|
||||||
print '<form method="post" action="'.$_SERVER["PHP_SELF"].'?mode=setup&driver='.$driver.'">';
|
print '<form method="post" action="'.$_SERVER["PHP_SELF"].'?mode=setup&driver='.$driver.'" autocomplete="off">';
|
||||||
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
|
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
|
||||||
print '<input type="hidden" name="action" value="setconst">';
|
print '<input type="hidden" name="action" value="setconst">';
|
||||||
|
|
||||||
dol_fiche_head($head, $mode, $langs->trans("ModuleDriverSetup"), 0, 'technic');
|
dol_fiche_head($head, $mode, $langs->trans("ModuleSetup"), 0, 'technic');
|
||||||
|
|
||||||
print $langs->trans("PrintingDriverDesc".$driver)."<br><br>\n";
|
print $langs->trans("PrintingDriverDesc".$driver)."<br><br>\n";
|
||||||
|
|
||||||
@ -128,18 +128,22 @@ if ($mode == 'setup' && $user->admin)
|
|||||||
print '<th>'.$langs->trans("Value").'</th>';
|
print '<th>'.$langs->trans("Value").'</th>';
|
||||||
print "</tr>\n";
|
print "</tr>\n";
|
||||||
|
|
||||||
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);
|
||||||
$printer = new $classname($db);
|
$printer = new $classname($db);
|
||||||
//print '<pre>'.print_r($printer, true).'</pre>';
|
//print '<pre>'.print_r($printer, true).'</pre>';
|
||||||
$i=0;
|
$i=0;
|
||||||
foreach ($printer->conf as $key) {
|
foreach ($printer->conf as $key)
|
||||||
|
{
|
||||||
$var=!$var;
|
$var=!$var;
|
||||||
print '<tr '.$bc[$var].'>';
|
print '<tr '.$bc[$var].'>';
|
||||||
print '<td'.($key['required']?' class=required':'').'>'.$langs->trans($key['varname']).'</td><td>';
|
print '<td'.($key['required']?' class=required':'').'>'.$langs->trans($key['varname']).'</td><td>';
|
||||||
print '<input size="32" type="'.(empty($key['type'])?'text':$key['type']).'" name="setupdriver['.$i.'][value]" value="'.$conf->global->{$key['varname']}.'">';
|
print '<input size="32" type="'.(empty($key['type'])?'text':$key['type']).'" name="setupdriver['.$i.'][value]" value="'.$conf->global->{$key['varname']}.'"';
|
||||||
|
print isset($key['moreattributes'])?$key['moreattributes']:'';
|
||||||
|
print '>';
|
||||||
print '<input type="hidden" name="setupdriver['.$i.'][varname]" value="'.$key['varname'].'">';
|
print '<input type="hidden" name="setupdriver['.$i.'][varname]" value="'.$key['varname'].'">';
|
||||||
print ' '.($key['example']!=''?$langs->trans("Example").' : '.$key['example']:'');
|
print ' '.($key['example']!=''?$langs->trans("Example").' : '.$key['example']:'');
|
||||||
print '</tr>';
|
print '</tr>';
|
||||||
@ -150,7 +154,8 @@ if ($mode == 'setup' && $user->admin)
|
|||||||
}
|
}
|
||||||
|
|
||||||
print '</table>';
|
print '</table>';
|
||||||
if (! empty($driver)) {
|
if (! empty($driver))
|
||||||
|
{
|
||||||
print '<div class="center"><input type="submit" class="button" value="'.dol_escape_htmltag($langs->trans("Modify")).'"></center>';
|
print '<div class="center"><input type="submit" class="button" value="'.dol_escape_htmltag($langs->trans("Modify")).'"></center>';
|
||||||
}
|
}
|
||||||
print '</form>';
|
print '</form>';
|
||||||
@ -170,7 +175,7 @@ if ($mode == 'config' && $user->admin)
|
|||||||
print '<th>'.$langs->trans("Description").'</th>';
|
print '<th>'.$langs->trans("Description").'</th>';
|
||||||
print '<th class="center">'.$langs->trans("Active").'</th>';
|
print '<th class="center">'.$langs->trans("Active").'</th>';
|
||||||
print '<th class="center">'.$langs->trans("Setup").'</th>';
|
print '<th class="center">'.$langs->trans("Setup").'</th>';
|
||||||
print '<th class="center">'.$langs->trans("Test").'</th>';
|
print '<th class="center">'.$langs->trans("TargetedPrinter").'</th>';
|
||||||
print "</tr>\n";
|
print "</tr>\n";
|
||||||
|
|
||||||
$object = new PrintingDriver($db);
|
$object = new PrintingDriver($db);
|
||||||
@ -212,12 +217,13 @@ if ($mode == 'config' && $user->admin)
|
|||||||
|
|
||||||
if ($mode == 'test' && $user->admin)
|
if ($mode == 'test' && $user->admin)
|
||||||
{
|
{
|
||||||
dol_fiche_head($head, $mode, $langs->trans("PrintingTest"), 0, 'technic');
|
dol_fiche_head($head, $mode, $langs->trans("ModuleSetup"), 0, 'technic');
|
||||||
|
|
||||||
print $langs->trans('PrintTestDesc'.$driver)."<br><br>\n";
|
print $langs->trans('PrintTestDesc'.$driver)."<br><br>\n";
|
||||||
|
|
||||||
print '<table class="noborder" width="100%">';
|
print '<table class="noborder" width="100%">';
|
||||||
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);
|
||||||
@ -235,7 +241,7 @@ if ($mode == 'test' && $user->admin)
|
|||||||
|
|
||||||
if ($mode == 'userconf' && $user->admin)
|
if ($mode == 'userconf' && $user->admin)
|
||||||
{
|
{
|
||||||
dol_fiche_head($head, $mode, $langs->trans("UserConf"), 0, 'technic');
|
dol_fiche_head($head, $mode, $langs->trans("ModuleSetup"), 0, 'technic');
|
||||||
|
|
||||||
print $langs->trans('PrintUserConfDesc'.$driver)."<br><br>\n";
|
print $langs->trans('PrintUserConfDesc'.$driver)."<br><br>\n";
|
||||||
|
|
||||||
|
|||||||
@ -26,9 +26,10 @@
|
|||||||
/**
|
/**
|
||||||
* Define head array for tabs of printing tools setup pages
|
* Define head array for tabs of printing tools setup pages
|
||||||
*
|
*
|
||||||
* @return Array of head
|
* @param $mode string Mode
|
||||||
|
* @return Array of head
|
||||||
*/
|
*/
|
||||||
function printingadmin_prepare_head()
|
function printingadmin_prepare_head($mode)
|
||||||
{
|
{
|
||||||
global $langs, $conf;
|
global $langs, $conf;
|
||||||
|
|
||||||
@ -40,20 +41,28 @@ function printingadmin_prepare_head()
|
|||||||
$head[$h][2] = 'config';
|
$head[$h][2] = 'config';
|
||||||
$h++;
|
$h++;
|
||||||
|
|
||||||
$head[$h][0] = DOL_URL_ROOT."/printing/admin/printing.php?mode=setup";
|
if ($mode == 'setup')
|
||||||
$head[$h][1] = $langs->trans("SetupDriver");
|
{
|
||||||
$head[$h][2] = 'setup';
|
$head[$h][0] = DOL_URL_ROOT."/printing/admin/printing.php?mode=setup";
|
||||||
$h++;
|
$head[$h][1] = $langs->trans("SetupDriver");
|
||||||
|
$head[$h][2] = 'setup';
|
||||||
|
$h++;
|
||||||
|
}
|
||||||
|
|
||||||
$head[$h][0] = DOL_URL_ROOT."/printing/admin/printing.php?mode=test";
|
if ($mode == 'test')
|
||||||
$head[$h][1] = $langs->trans("TestDriver");
|
{
|
||||||
$head[$h][2] = 'test';
|
$head[$h][0] = DOL_URL_ROOT."/printing/admin/printing.php?mode=test";
|
||||||
$h++;
|
$head[$h][1] = $langs->trans("TargetedPrinter");
|
||||||
|
$head[$h][2] = 'test';
|
||||||
|
$h++;
|
||||||
|
}
|
||||||
|
|
||||||
$head[$h][0] = DOL_URL_ROOT."/printing/admin/printing.php?mode=userconf";
|
/** TODO This feature seem to be not ready yet.
|
||||||
$head[$h][1] = $langs->trans("UserConf");
|
$head[$h][0] = DOL_URL_ROOT."/printing/admin/printing.php?mode=userconf";
|
||||||
$head[$h][2] = 'userconf';
|
$head[$h][1] = $langs->trans("UserConf");
|
||||||
$h++;
|
$head[$h][2] = 'userconf';
|
||||||
|
$h++;
|
||||||
|
*/
|
||||||
|
|
||||||
//$object=new stdClass();
|
//$object=new stdClass();
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user