25 require
'../../main.inc.php';
27 require_once DOL_DOCUMENT_ROOT.
'/core/lib/admin.lib.php';
28 require_once DOL_DOCUMENT_ROOT.
'/core/class/doleditor.class.php';
29 require_once DOL_DOCUMENT_ROOT.
'/core/modules/printing/modules_printing.php';
30 require_once DOL_DOCUMENT_ROOT.
'/printing/lib/printing.lib.php';
31 use OAuth\Common\Storage\DoliStorage;
34 $langs->loadLangs(array(
'admin',
'printing',
'oauth'));
36 $action =
GETPOST(
'action',
'aZ09');
37 $mode =
GETPOST(
'mode',
'alpha');
38 $value =
GETPOST(
'value',
'alpha', 0, null, null, 1);
39 $varname =
GETPOST(
'varname',
'alpha');
40 $driver =
GETPOST(
'driver',
'alpha');
42 if (!empty($driver)) {
43 $langs->load($driver);
50 $OAUTH_SERVICENAME_GOOGLE =
'Google';
61 if (($mode ==
'test' || $mode ==
'setup') && empty($driver)) {
63 header(
"Location: ".$_SERVER[
'PHP_SELF'].
'?mode=config');
67 if ($action ==
'setconst' && $user->admin) {
70 foreach ($_POST[
'setupdriver'] as $setupconst) {
72 $result =
dolibarr_set_const($db, $setupconst[
'varname'], $setupconst[
'value'],
'chaine', 0,
'', $conf->entity);
88 if ($action ==
'setvalue' && $user->admin) {
113 llxHeader(
'', $langs->trans(
"PrintingSetup"));
115 $linkback =
'<a href="'.DOL_URL_ROOT.
'/admin/modules.php?restore_lastsearch_values=1">'.$langs->trans(
"BackToModuleList").
'</a>';
116 print
load_fiche_titre($langs->trans(
"PrintingSetup"), $linkback,
'title_setup');
120 if ($mode ==
'setup' && $user->admin) {
121 print
'<form method="post" action="'.$_SERVER[
"PHP_SELF"].
'?mode=setup&driver='.$driver.
'" autocomplete="off">';
122 print
'<input type="hidden" name="token" value="'.newToken().
'">';
123 print
'<input type="hidden" name="action" value="setconst">';
127 print $langs->trans(
"PrintingDriverDesc".$driver).
"<br><br>\n";
129 print
'<table class="noborder centpercent">'.
"\n";
130 print
'<tr class="liste_titre">';
131 print
'<th>'.$langs->trans(
"Parameters").
'</th>';
132 print
'<th>'.$langs->trans(
"Value").
'</th>';
133 print
'<th> </th>';
137 if (!empty($driver)) {
138 if (!empty($conf->modules_parts[
'printing'])) {
139 $dirmodels = array_merge(array(
'/core/modules/printing/'), (array) $conf->modules_parts[
'printing']);
141 $dirmodels = array(
'/core/modules/printing/');
144 foreach ($dirmodels as $dir) {
145 if (file_exists(
dol_buildpath($dir, 0).$driver.
'.modules.php')) {
150 require_once $classfile;
151 $classname =
'printing_'.$driver;
152 $printer =
new $classname($db);
153 $langs->load($printer::LANGFILE);
157 foreach ($printer->conf as $key) {
158 switch ($key[
'type']) {
161 print
'<tr class="oddeven">';
162 print
'<td'.($key[
'required'] ?
' class=required' :
'').
'>'.$langs->trans($key[
'varname']).
'</td>';
163 print
'<td><input size="32" type="'.(empty($key[
'type']) ?
'text' : $key[
'type']).
'" name="setupdriver['.$i.
'][value]" value="'.$conf->global->{$key[
'varname']}.
'"';
164 print isset($key[
'moreattributes']) ?
' '.$key[
'moreattributes'] :
'';
165 print
'><input type="hidden" name="setupdriver['.$i.
'][varname]" value="'.$key[
'varname'].
'"></td>';
166 print
'<td> '.($key[
'example'] !=
'' ? $langs->trans(
"Example").
' : '.$key[
'example'] :
'').
'</td>';
170 print
'<tr class="oddeven">';
171 print
'<td'.($key[
'required'] ?
' class=required' :
'').
'>';
172 if ($key[
'varname'] ==
'PRINTGCP_TOKEN_ACCESS') {
173 print $langs->trans(
"IsTokenGenerated");
175 print $langs->trans($key[
'varname']);
178 print
'<td>'.$langs->trans($key[
'info']).
'</td>';
181 if ($key[
'varname'] ==
'PRINTGCP_TOKEN_ACCESS') {
183 if (!empty($key[
'delete'])) {
184 print
'<a class="button" href="'.$key[
'delete'].
'">'.$langs->trans(
'DeleteAccess').
'</a><br><br>';
187 print
'<a class="button" href="'.$key[
'renew'].
'">'.$langs->trans(
'RequestAccess').
'</a><br><br>';
189 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>';
195 if ($key[
'enabled']) {
202 if ($key[
'varname'] ==
'PRINTGCP_TOKEN_ACCESS') {
204 print
'<tr class="oddeven">';
205 print
'<td>'.$langs->trans(
"Token").
'</td>';
206 print
'<td colspan="2">';
209 $storage =
new DoliStorage($db, $conf);
211 $tokenobj = $storage->retrieveAccessToken($OAUTH_SERVICENAME_GOOGLE);
215 if (is_object($tokenobj)) {
217 print $tokenobj->getAccessToken().
'<br>';
230 print $langs->trans(
'PleaseSelectaDriverfromList');
237 if (!empty($driver)) {
238 if ($submit_enabled) {
239 print
'<div class="center"><input type="submit" class="button" value="'.dol_escape_htmltag($langs->trans(
"Modify")).
'"></div>';
245 if ($mode ==
'config' && $user->admin) {
248 print $langs->trans(
"PrintingDesc").
"<br><br>\n";
250 print
'<table class="noborder centpercent">'.
"\n";
252 print
'<tr class="liste_titre">';
253 print
'<th>'.$langs->trans(
"Description").
'</th>';
254 print
'<th class="center">'.$langs->trans(
"Active").
'</th>';
255 print
'<th class="center">'.$langs->trans(
"Setup").
'</th>';
256 print
'<th class="center">'.$langs->trans(
"TargetedPrinter").
'</th>';
260 $result = $object->listDrivers($db, 10);
262 if (!empty($conf->modules_parts[
'printing'])) {
263 $dirmodels = array_merge(array(
'/core/modules/printing/'), (array) $conf->modules_parts[
'printing']);
265 $dirmodels = array(
'/core/modules/printing/');
268 foreach ($result as $driver) {
269 foreach ($dirmodels as $dir) {
270 if (file_exists(
dol_buildpath($dir, 0).$driver.
'.modules.php')) {
275 require_once $classfile;
276 $classname =
'printing_'.$driver;
277 $printer =
new $classname($db);
278 $langs->load($printer::LANGFILE);
281 print
'<tr class="oddeven">';
282 print
'<td>'.img_picto(
'', $printer->picto).
' '.$langs->trans($printer->desc).
'</td>';
283 print
'<td class="center">';
284 if (!empty($conf->use_javascript_ajax)) {
287 if (empty($conf->global->{$printer->conf})) {
288 print
'<a href="'.$_SERVER[
'PHP_SELF'].
'?action=setvalue&token='.
newToken().
'&varname='.urlencode($printer->active).
'&value=1">'.
img_picto($langs->trans(
"Disabled"),
'off').
'</a>';
290 print
'<a href="'.$_SERVER[
'PHP_SELF'].
'?action=setvalue&token='.
newToken().
'&varname='.urlencode($printer->active).
'&value=0">'.
img_picto($langs->trans(
"Enabled"),
'on').
'</a>';
293 print
'<td class="center"><a href="'.$_SERVER[
'PHP_SELF'].
'?mode=setup&token='.
newToken().
'&driver='.urlencode($printer->name).
'">'.
img_picto(
'',
'setup').
'</a></td>';
294 print
'<td class="center"><a href="'.$_SERVER[
'PHP_SELF'].
'?mode=test&token='.
newToken().
'&driver='.urlencode($printer->name).
'">'.
img_picto(
'',
'setup').
'</a></td>';
303 if ($mode ==
'test' && $user->admin) {
306 print $langs->trans(
'PrintTestDesc'.$driver).
"<br><br>\n";
308 print
'<table class="noborder centpercent">';
309 if (!empty($driver)) {
310 if (!empty($conf->modules_parts[
'printing'])) {
311 $dirmodels = array_merge(array(
'/core/modules/printing/'), (array) $conf->modules_parts[
'printing']);
313 $dirmodels = array(
'/core/modules/printing/');
316 foreach ($dirmodels as $dir) {
317 if (file_exists(
dol_buildpath($dir, 0).$driver.
'.modules.php')) {
322 require_once $classfile;
323 $classname =
'printing_'.$driver;
324 $langs->load($driver);
325 $printer =
new $classname($db);
326 $langs->load($printer::LANGFILE);
328 if (count($printer->getlistAvailablePrinters())) {
329 if ($printer->listAvailablePrinters() == 0) {
330 print $printer->resprint;
335 print $langs->trans(
'PleaseConfigureDriverfromList');
338 print $langs->trans(
'PleaseSelectaDriverfromList');
345 if ($mode ==
'userconf' && $user->admin) {
348 print $langs->trans(
'PrintUserConfDesc'.$driver).
"<br><br>\n";
350 print
'<table class="noborder centpercent">';
351 print
'<tr class="liste_titre">';
352 print
'<th>'.$langs->trans(
"User").
'</th>';
353 print
'<th>'.$langs->trans(
"PrintModule").
'</th>';
354 print
'<th>'.$langs->trans(
"PrintDriver").
'</th>';
355 print
'<th>'.$langs->trans(
"Printer").
'</th>';
356 print
'<th>'.$langs->trans(
"PrinterLocation").
'</th>';
357 print
'<th>'.$langs->trans(
"PrinterId").
'</th>';
358 print
'<th>'.$langs->trans(
"NumberOfCopy").
'</th>';
359 print
'<th class="center">'.$langs->trans(
"Delete").
'</th>';
361 $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';
362 $resql = $db->query($sql);
363 while ($row = $db->fetch_array(
$resql)) {
364 print
'<tr class="oddeven">';
365 print
'<td>'.$row[
'login'].
'</td>';
366 print
'<td>'.$row[
'module'].
'</td>';
367 print
'<td>'.$row[
'driver'].
'</td>';
368 print
'<td>'.$row[
'printer_name'].
'</td>';
369 print
'<td>'.$row[
'printer_location'].
'</td>';
370 print
'<td>'.$row[
'printer_id'].
'</td>';
371 print
'<td>'.$row[
'copy'].
'</td>';
372 print
'<td class="center">'.img_picto($langs->trans(
"Delete"),
'delete').
'</td>';
GETPOST($paramname, $check= 'alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
if($cancel &&!$id) if($action== 'add'&&!$cancel) if($action== 'delete') if($id) $form
Actions.
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('NOCSRFCHECK')) if(!defined('NOTOKENRENEWAL')) if(!defined('NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined('NOREQUIREAJAX')) llxHeader()
Empty header.
Parent class of emailing target selectors modules.
dol_buildpath($path, $type=0, $returnemptyifnotfound=0)
Return path of url or filesystem.
setEventMessages($mesg, $mesgs, $style= 'mesgs', $messagekey= '')
Set event messages in dol_events session object.
load_fiche_titre($titre, $morehtmlright= '', $picto= 'generic', $pictoisfullpath=0, $id= '', $morecssontable= '', $morehtmlcenter= '')
Load a title with picto.
img_picto($titlealt, $picto, $moreatt= '', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt= '', $morecss= '', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
accessforbidden($message= '', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program Calling this function terminate execution ...
if(isModEnabled('facture')&&!empty($user->rights->facture->lire)) if((isModEnabled('fournisseur')&&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)&&$user->rights->fournisseur->facture->lire)||(isModEnabled('supplier_invoice')&&$user->rights->supplier_invoice->lire)) if(isModEnabled('don')&&!empty($user->rights->don->lire)) if(isModEnabled('tax')&&!empty($user->rights->tax->charges->lire)) if(isModEnabled('facture')&&isModEnabled('commande')&&$user->rights->commande->lire &&empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) $resql
Social contributions to pay.
dol_get_fiche_head($links=array(), $active= '', $title= '', $notab=0, $picto= '', $pictoisfullpath=0, $morehtmlright= '', $morecss= '', $limittoshow=0, $moretabssuffix= '')
Show tabs of a record.
printingAdminPrepareHead($mode)
Define head array for tabs of printing tools setup pages.
dol_print_error($db= '', $error= '', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
newToken()
Return the value of token currently saved into session with name 'newtoken'.
dol_get_fiche_end($notab=0)
Return tab footer of a card.
ajax_constantonoff($code, $input=array(), $entity=null, $revertonoff=0, $strict=0, $forcereload=0, $marginleftonlyshort=2, $forcenoajax=0, $setzeroinsteadofdel=0, $suffix= '', $mode= '')
On/off button for constant.