27require
'../../main.inc.php';
29require_once DOL_DOCUMENT_ROOT.
'/core/lib/admin.lib.php';
30require_once DOL_DOCUMENT_ROOT.
'/core/class/doleditor.class.php';
31require_once DOL_DOCUMENT_ROOT.
'/core/modules/printing/modules_printing.php';
32require_once DOL_DOCUMENT_ROOT.
'/printing/lib/printing.lib.php';
33use OAuth\Common\Storage\DoliStorage;
44$langs->loadLangs(array(
'admin',
'printing',
'oauth'));
46$action =
GETPOST(
'action',
'aZ09');
47$mode =
GETPOST(
'mode',
'alpha');
48$value =
GETPOST(
'value',
'alpha', 0,
null,
null, 1);
49$varname =
GETPOST(
'varname',
'alpha');
50$driver =
GETPOST(
'driver',
'alpha');
53 $langs->load($driver);
60$OAUTH_SERVICENAME_GOOGLE =
'Google';
72if (($mode ==
'test' || $mode ==
'setup') && empty($driver)) {
74 header(
"Location: ".$_SERVER[
'PHP_SELF'].
'?mode=config');
78if ($action ==
'setconst' && $user->admin) {
80 foreach ($_POST[
'setupdriver'] as $setupconst) {
81 '@phan-var-force array<string,string> $setupconst';
83 $result =
dolibarr_set_const($db, $setupconst[
'varname'], $setupconst[
'value'],
'chaine', 0,
'',
$conf->entity);
99if ($action ==
'setvalue' && $user->admin) {
103 if (!($result > 0)) {
122$form =
new Form($db);
124llxHeader(
'', $langs->trans(
"PrintingSetup"));
126$linkback =
'<a href="'.DOL_URL_ROOT.
'/admin/modules.php?restore_lastsearch_values=1">'.$langs->trans(
"BackToModuleList").
'</a>';
127print
load_fiche_titre($langs->trans(
"PrintingSetup"), $linkback,
'title_setup');
131if ($mode ==
'setup' && $user->admin) {
132 print
'<form method="post" action="'.$_SERVER[
"PHP_SELF"].
'?mode=setup&driver='.$driver.
'" autocomplete="off">';
133 print
'<input type="hidden" name="token" value="'.newToken().
'">';
134 print
'<input type="hidden" name="action" value="setconst">';
138 print $langs->trans(
"PrintingDriverDesc".$driver).
"<br><br>\n";
140 print
'<table class="noborder centpercent">'.
"\n";
141 print
'<tr class="liste_titre">';
142 print
'<th>'.$langs->trans(
"Parameters").
'</th>';
143 print
'<th>'.$langs->trans(
"Value").
'</th>';
144 print
'<th> </th>';
148 if (!empty($driver)) {
149 if (!empty(
$conf->modules_parts[
'printing'])) {
150 $dirmodels = array_merge(array(
'/core/modules/printing/'), (array)
$conf->modules_parts[
'printing']);
152 $dirmodels = array(
'/core/modules/printing/');
155 foreach ($dirmodels as $dir) {
156 if (file_exists(
dol_buildpath($dir, 0).$driver.
'.modules.php')) {
161 require_once $classfile;
162 $classname =
'printing_'.$driver;
163 $printer =
new $classname($db);
164 $langs->load(
'printing');
168 foreach ($printer->conf as $key) {
169 switch ($key[
'type']) {
172 print
'<tr class="oddeven">';
173 print
'<td'.($key[
'required'] ?
' class=required' :
'').
'>'.$langs->trans($key[
'varname']).
'</td>';
174 print
'<td><input class="width100" type="'.(empty($key[
'type']) ?
'text' : $key[
'type']).
'" name="setupdriver['.$i.
'][value]" value="'.
getDolGlobalString($key[
'varname']).
'"';
175 print isset($key[
'moreattributes']) ?
' '.$key[
'moreattributes'] :
'';
176 print
'><input type="hidden" name="setupdriver['.$i.
'][varname]" value="'.$key[
'varname'].
'"></td>';
177 print
'<td> '.($key[
'example'] !=
'' ? $langs->trans(
"Example").
' : '.$key[
'example'] :
'').
'</td>';
181 print
'<tr class="oddeven">';
182 print
'<td'.($key[
'required'] ?
' class=required' :
'').
'>'.$langs->trans($key[
'varname']).
'</td>';
183 print
'<td><input class="width100" type="'.(empty($key[
'type']) ?
'text' : $key[
'type']).
'" name="setupdriver['.$i.
'][value]" value="1" '.((
getDolGlobalInt($key[
'varname'])) ?
'checked' :
'');
184 print isset($key[
'moreattributes']) ?
' '.$key[
'moreattributes'] :
'';
185 print
'><input type="hidden" name="setupdriver['.$i.
'][varname]" value="'.$key[
'varname'].
'"></td>';
186 print
'<td> '.($key[
'example'] !=
'' ? $langs->trans(
"Example").
' : '.$key[
'example'] :
'').
'</td>';
190 print
'<tr class="oddeven">';
191 print
'<td'.($key[
'required'] ?
' class=required' :
'').
'>';
192 if ($key[
'varname'] ==
'PRINTGCP_TOKEN_ACCESS') {
193 print $langs->trans(
"IsTokenGenerated");
195 print $langs->trans($key[
'varname']);
198 print
'<td>'.$langs->trans($key[
'info']).
'</td>';
201 if ($key[
'varname'] ==
'PRINTGCP_TOKEN_ACCESS') {
203 if (!empty($key[
'delete'])) {
204 print
'<a class="button" href="'.$key[
'delete'].
'">'.$langs->trans(
'DeleteAccess').
'</a><br><br>';
207 print
'<a class="button" href="'.$key[
'renew'].
'">'.$langs->trans(
'RequestAccess').
'</a><br><br>';
209 print $langs->trans(
"ToCheckDeleteTokenOnProvider", $OAUTH_SERVICENAME_GOOGLE).
': <a href="https://security.google.com/settings/security/permissions" target="_google">https://security.google.com/settings/security/permissions</a>';
215 if ($key[
'enabled']) {
222 if ($key[
'varname'] ==
'PRINTGCP_TOKEN_ACCESS') {
223 $keyforprovider =
'';
226 print
'<tr class="oddeven">';
227 print
'<td>'.$langs->trans(
"Token").
'</td>';
228 print
'<td colspan="2">';
231 $storage =
new DoliStorage($db,
$conf, $keyforprovider);
233 $tokenobj = $storage->retrieveAccessToken($OAUTH_SERVICENAME_GOOGLE);
237 if (is_object($tokenobj)) {
239 print $tokenobj->getAccessToken().
'<br>';
252 print $langs->trans(
'PleaseSelectaDriverfromList');
259 if (!empty($driver)) {
260 if ($submit_enabled) {
261 print
'<div class="center"><input type="submit" class="button" value="'.dol_escape_htmltag($langs->trans(
"Save")).
'"></div>';
267if ($mode ==
'config' && $user->admin) {
270 print $langs->trans(
"PrintingDesc").
"<br><br>\n";
272 print
'<table class="noborder centpercent">'.
"\n";
274 print
'<tr class="liste_titre">';
275 print
'<th>'.$langs->trans(
"Description").
'</th>';
276 print
'<th class="center">'.$langs->trans(
"Active").
'</th>';
277 print
'<th class="center">'.$langs->trans(
"Setup").
'</th>';
278 print
'<th class="center">'.$langs->trans(
"TargetedPrinter").
'</th>';
282 $result =
$object->listDrivers($db, 10);
284 if (!empty(
$conf->modules_parts[
'printing'])) {
285 $dirmodels = array_merge(array(
'/core/modules/printing/'), (array)
$conf->modules_parts[
'printing']);
287 $dirmodels = array(
'/core/modules/printing/');
290 foreach ($result as $tmpdriver) {
291 foreach ($dirmodels as $dir) {
292 if (file_exists(
dol_buildpath($dir, 0).$tmpdriver.
'.modules.php')) {
293 $classfile =
dol_buildpath($dir, 0).$tmpdriver.
'.modules.php';
297 require_once $classfile;
298 $classname =
'printing_'.$tmpdriver;
299 $printer =
new $classname($db);
300 $langs->load(
'printing');
303 print
'<tr class="oddeven">';
304 print
'<td>'.img_picto(
'', $printer->picto).
' '.$langs->trans($printer->desc).
'</td>';
305 print
'<td class="center">';
306 if (!empty(
$conf->use_javascript_ajax)) {
307 print ajax_constantonoff($printer->active);
310 print
'<a href="'.$_SERVER[
'PHP_SELF'].
'?action=setvalue&token='.
newToken().
'&varname='.urlencode($printer->active).
'&value=1">'.
img_picto($langs->trans(
"Disabled"),
'off').
'</a>';
312 print
'<a href="'.$_SERVER[
'PHP_SELF'].
'?action=setvalue&token='.
newToken().
'&varname='.urlencode($printer->active).
'&value=0">'.
img_picto($langs->trans(
"Enabled"),
'on').
'</a>';
315 print
'<td class="center"><a href="'.$_SERVER[
'PHP_SELF'].
'?mode=setup&token='.
newToken().
'&driver='.urlencode($printer->name).
'">'.
img_picto(
'',
'setup').
'</a></td>';
316 print
'<td class="center"><a href="'.$_SERVER[
'PHP_SELF'].
'?mode=test&token='.
newToken().
'&driver='.urlencode($printer->name).
'">'.
img_picto(
'',
'setup').
'</a></td>';
325if ($mode ==
'test' && $user->admin) {
328 print $langs->trans(
'PrintTestDesc'.$driver).
"<br><br>\n";
330 print
'<table class="noborder centpercent">';
331 if (!empty($driver)) {
332 if (!empty(
$conf->modules_parts[
'printing'])) {
333 $dirmodels = array_merge(array(
'/core/modules/printing/'), (array)
$conf->modules_parts[
'printing']);
335 $dirmodels = array(
'/core/modules/printing/');
338 foreach ($dirmodels as $dir) {
339 if (file_exists(
dol_buildpath($dir, 0).$driver.
'.modules.php')) {
344 require_once $classfile;
345 $classname =
'printing_'.$driver;
346 $printer =
new $classname($db);
347 '@phan-var-force PrintingDriver $printer';
348 $langs->load($driver);
349 $langs->load(
'printing');
352 if (count($printer->getlistAvailablePrinters())) {
353 if ($printer->listAvailablePrinters() == 0) {
354 print $printer->resprint;
359 print $langs->trans(
'PleaseConfigureDriverfromList');
362 print $langs->trans(
'PleaseSelectaDriverfromList');
369if ($mode ==
'userconf' && $user->admin) {
372 print $langs->trans(
'PrintUserConfDesc'.$driver).
"<br><br>\n";
374 print
'<table class="noborder centpercent">';
375 print
'<tr class="liste_titre">';
376 print
'<th>'.$langs->trans(
"User").
'</th>';
377 print
'<th>'.$langs->trans(
"PrintModule").
'</th>';
378 print
'<th>'.$langs->trans(
"PrintDriver").
'</th>';
379 print
'<th>'.$langs->trans(
"Printer").
'</th>';
380 print
'<th>'.$langs->trans(
"PrinterLocation").
'</th>';
381 print
'<th>'.$langs->trans(
"PrinterId").
'</th>';
382 print
'<th>'.$langs->trans(
"NumberOfCopy").
'</th>';
383 print
'<th class="center">'.$langs->trans(
"Delete").
'</th>';
385 $sql =
'SELECT p.rowid, p.printer_name, p.printer_location, p.printer_id, p.copy, p.module, p.driver, p.userid, u.login FROM '.MAIN_DB_PREFIX.
'printing as p, '.MAIN_DB_PREFIX.
'user as u WHERE p.userid=u.rowid';
386 $resql = $db->query($sql);
387 while ($row = $db->fetch_array($resql)) {
388 print
'<tr class="oddeven">';
389 print
'<td>'.$row[
'login'].
'</td>';
390 print
'<td>'.$row[
'module'].
'</td>';
391 print
'<td>'.$row[
'driver'].
'</td>';
392 print
'<td>'.$row[
'printer_name'].
'</td>';
393 print
'<td>'.$row[
'printer_location'].
'</td>';
394 print
'<td>'.$row[
'printer_id'].
'</td>';
395 print
'<td>'.$row[
'copy'].
'</td>';
396 print
'<td class="center">'.img_picto($langs->trans(
"Delete"),
'delete').
'</td>';
if( $user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $object
dolibarr_set_const($db, $name, $value, $type='chaine', $visible=0, $note='', $entity=1)
Insert a parameter (key,value) into database (delete old key then insert it again).
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader($head='', $title='', $help_url='', $target='', $disablejs=0, $disablehead=0, $arrayofjs='', $arrayofcss='', $morequerystring='', $morecssonbody='', $replacemainareaby='', $disablenofollow=0, $disablenoindex=0)
Empty header.
Parent class of emailing target selectors modules.
load_fiche_titre($title, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0, $attop=0)
Set event messages in dol_events session object.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limittoshow=0, $moretabssuffix='', $dragdropfile=0)
Show tabs of a record.
dol_get_fiche_end($notab=0)
Return tab footer of a card.
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
newToken()
Return the value of token currently saved into session with name 'newtoken'.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
dol_buildpath($path, $type=0, $returnemptyifnotfound=0)
Return path of url or filesystem.
dol_print_error($db=null, $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
global $conf
The following vars must be defined: $type2label $form $conf, $lang, The following vars may also be de...
printingAdminPrepareHead($mode)
Define head array for tabs of printing tools setup pages.
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.