can add a driver for printing in module
This commit is contained in:
parent
a729bff062
commit
81f6a7abb6
@ -66,12 +66,17 @@ class PrintingDriver
|
||||
$type = 'printing';
|
||||
$list = array();
|
||||
|
||||
$moduledir = DOL_DOCUMENT_ROOT."/core/modules/printing/";
|
||||
$tmpfiles = dol_dir_list($moduledir, 'all', 0, '\modules.php', '', 'name', SORT_ASC, 0);
|
||||
foreach ($tmpfiles as $record) {
|
||||
$listoffiles = array();
|
||||
$dirmodels = array_merge(array('/core/modules/printing/'), (array) $conf->modules_parts['printing']);
|
||||
foreach ($dirmodels as $dir) {
|
||||
$tmpfiles = dol_dir_list(dol_buildpath($dir, 0), 'all', 0, '\modules.php', '', 'name', SORT_ASC, 0);
|
||||
if (!empty($tmpfiles)) {
|
||||
$listoffiles = array_merge($listoffiles, $tmpfiles);
|
||||
}
|
||||
}
|
||||
foreach ($listoffiles as $record) {
|
||||
$list[$record['fullname']] = str_replace('.modules.php', '', $record['name']);
|
||||
}
|
||||
|
||||
}
|
||||
return $list;
|
||||
}
|
||||
|
||||
|
||||
@ -68,6 +68,7 @@ class printing_printgcp extends PrintingDriver
|
||||
const PRINTERS_SEARCH_URL = 'https://www.google.com/cloudprint/search';
|
||||
const PRINTERS_GET_JOBS = 'https://www.google.com/cloudprint/jobs';
|
||||
const PRINT_URL = 'https://www.google.com/cloudprint/submit';
|
||||
const LANGFILE = 'printgcp';
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
|
||||
@ -60,6 +60,8 @@ class printing_printipp extends PrintingDriver
|
||||
*/
|
||||
public $db;
|
||||
|
||||
const LANGFILE = 'printipp';
|
||||
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
|
||||
@ -90,6 +90,8 @@ class modMyModule extends DolibarrModules
|
||||
'barcode' => 0,
|
||||
// Set this to 1 if module has its own models directory (core/modules/xxx)
|
||||
'models' => 0,
|
||||
// Set this to 1 if module has its own printing directory (core/modules/printing)
|
||||
'printing' => 0,
|
||||
// Set this to 1 if module has its own theme directory (theme)
|
||||
'theme' => 0,
|
||||
// Set this to relative path of css file if module has its own css file
|
||||
|
||||
@ -69,8 +69,7 @@ if ($action == 'setconst' && $user->admin)
|
||||
if (!$result > 0) $error++;
|
||||
}
|
||||
|
||||
if (!$error)
|
||||
{
|
||||
if (!$error) {
|
||||
$db->commit();
|
||||
setEventMessages($langs->trans("SetupSaved"), null);
|
||||
} else {
|
||||
@ -87,8 +86,7 @@ if ($action == 'setvalue' && $user->admin)
|
||||
$result = dolibarr_set_const($db, $varname, $value, 'chaine', 0, '', $conf->entity);
|
||||
if (!$result > 0) $error++;
|
||||
|
||||
if (!$error)
|
||||
{
|
||||
if (!$error) {
|
||||
$db->commit();
|
||||
setEventMessages($langs->trans("SetupSaved"), null);
|
||||
} else {
|
||||
@ -131,10 +129,17 @@ if ($mode == 'setup' && $user->admin)
|
||||
$submit_enabled = 0;
|
||||
|
||||
if (!empty($driver)) {
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/modules/printing/'.$driver.'.modules.php';
|
||||
$dirmodels = array_merge(array('/core/modules/printing/'), (array) $conf->modules_parts['printing']);
|
||||
foreach ($dirmodels as $dir) {
|
||||
if (file_exists(dol_buildpath($dir, 0).$driver.'.modules.php')) {
|
||||
$classfile = dol_buildpath($dir, 0).$driver.'.modules.php';
|
||||
break;
|
||||
}
|
||||
}
|
||||
require_once $classfile;
|
||||
$classname = 'printing_'.$driver;
|
||||
$langs->load($driver);
|
||||
$printer = new $classname($db);
|
||||
$langs->load($printer::LANGFILE);
|
||||
|
||||
$i = 0;
|
||||
$submit_enabled = 0;
|
||||
@ -246,22 +251,27 @@ if ($mode == 'config' && $user->admin)
|
||||
|
||||
$object = new PrintingDriver($db);
|
||||
$result = $object->listDrivers($db, 10);
|
||||
$dirmodels = array_merge(array('/core/modules/printing/'), (array) $conf->modules_parts['printing']);
|
||||
foreach ($result as $driver) {
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/modules/printing/'.$driver.'.modules.php';
|
||||
foreach ($dirmodels as $dir) {
|
||||
if (file_exists(dol_buildpath($dir, 0).$driver.'.modules.php')) {
|
||||
$classfile = dol_buildpath($dir, 0).$driver.'.modules.php';
|
||||
break;
|
||||
}
|
||||
}
|
||||
require_once $classfile;
|
||||
$classname = 'printing_'.$driver;
|
||||
$langs->load($driver);
|
||||
$printer = new $classname($db);
|
||||
$langs->load($printer::LANGFILE);
|
||||
//print '<pre>'.print_r($printer, true).'</pre>';
|
||||
|
||||
print '<tr class="oddeven">';
|
||||
print '<td>'.img_picto('', $printer->picto).' '.$langs->trans($printer->desc).'</td>';
|
||||
print '<td class="center">';
|
||||
if (!empty($conf->use_javascript_ajax))
|
||||
{
|
||||
if (!empty($conf->use_javascript_ajax)) {
|
||||
print ajax_constantonoff($printer->active);
|
||||
} else {
|
||||
if (empty($conf->global->{$printer->conf}))
|
||||
{
|
||||
if (empty($conf->global->{$printer->conf})) {
|
||||
print '<a href="'.$_SERVER['PHP_SELF'].'?action=setvalue&token='.newToken().'&varname='.$printer->active.'&value=1">'.img_picto($langs->trans("Disabled"), 'off').'</a>';
|
||||
} else {
|
||||
print '<a href="'.$_SERVER['PHP_SELF'].'?action=setvalue&token='.newToken().'&varname='.$printer->active.'&value=0">'.img_picto($langs->trans("Enabled"), 'on').'</a>';
|
||||
@ -284,12 +294,19 @@ if ($mode == 'test' && $user->admin)
|
||||
print $langs->trans('PrintTestDesc'.$driver)."<br><br>\n";
|
||||
|
||||
print '<table class="noborder centpercent">';
|
||||
if (!empty($driver))
|
||||
{
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/modules/printing/'.$driver.'.modules.php';
|
||||
if (!empty($driver)) {
|
||||
$dirmodels = array_merge(array('/core/modules/printing/'), (array) $conf->modules_parts['printing']);
|
||||
foreach ($dirmodels as $dir) {
|
||||
if (file_exists(dol_buildpath($dir, 0).$driver.'.modules.php')) {
|
||||
$classfile = dol_buildpath($dir, 0).$driver.'.modules.php';
|
||||
break;
|
||||
}
|
||||
}
|
||||
require_once $classfile;
|
||||
$classname = 'printing_'.$driver;
|
||||
$langs->load($driver);
|
||||
$printer = new $classname($db);
|
||||
$langs->load($printer::LANGFILE);
|
||||
//print '<pre>'.print_r($printer, true).'</pre>';
|
||||
if (count($printer->getlistAvailablePrinters())) {
|
||||
if ($printer->listAvailablePrinters() == 0) {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user