26 require
'../../main.inc.php';
28 require_once DOL_DOCUMENT_ROOT.
'/core/lib/admin.lib.php';
29 require_once DOL_DOCUMENT_ROOT.
'/core/class/doleditor.class.php';
30 require_once DOL_DOCUMENT_ROOT.
'/core/modules/printing/modules_printing.php';
31 require_once DOL_DOCUMENT_ROOT.
'/printing/lib/printing.lib.php';
32 use OAuth\Common\Storage\DoliStorage;
35 $langs->loadLangs(array(
'admin',
'printing',
'oauth'));
37 $action =
GETPOST(
'action',
'aZ09');
38 $mode =
GETPOST(
'mode',
'alpha');
39 $value =
GETPOST(
'value',
'alpha', 0,
null,
null, 1);
40 $varname =
GETPOST(
'varname',
'alpha');
41 $driver =
GETPOST(
'driver',
'alpha');
43 if (!empty($driver)) {
44 $langs->load($driver);
51 $OAUTH_SERVICENAME_GOOGLE =
'Google';
62 if (($mode ==
'test' || $mode ==
'setup') && empty($driver)) {
64 header(
"Location: ".$_SERVER[
'PHP_SELF'].
'?mode=config');
68 if ($action ==
'setconst' && $user->admin) {
71 foreach ($_POST[
'setupdriver'] as $setupconst) {
73 $result =
dolibarr_set_const($db, $setupconst[
'varname'], $setupconst[
'value'],
'chaine', 0,
'', $conf->entity);
89 if ($action ==
'setvalue' && $user->admin) {
114 llxHeader(
'', $langs->trans(
"PrintingSetup"));
116 $linkback =
'<a href="'.DOL_URL_ROOT.
'/admin/modules.php?restore_lastsearch_values=1">'.$langs->trans(
"BackToModuleList").
'</a>';
117 print
load_fiche_titre($langs->trans(
"PrintingSetup"), $linkback,
'title_setup');
121 if ($mode ==
'setup' && $user->admin) {
122 print
'<form method="post" action="'.$_SERVER[
"PHP_SELF"].
'?mode=setup&driver='.$driver.
'" autocomplete="off">';
123 print
'<input type="hidden" name="token" value="'.newToken().
'">';
124 print
'<input type="hidden" name="action" value="setconst">';
128 print $langs->trans(
"PrintingDriverDesc".$driver).
"<br><br>\n";
130 print
'<table class="noborder centpercent">'.
"\n";
131 print
'<tr class="liste_titre">';
132 print
'<th>'.$langs->trans(
"Parameters").
'</th>';
133 print
'<th>'.$langs->trans(
"Value").
'</th>';
134 print
'<th> </th>';
138 if (!empty($driver)) {
139 if (!empty($conf->modules_parts[
'printing'])) {
140 $dirmodels = array_merge(array(
'/core/modules/printing/'), (array) $conf->modules_parts[
'printing']);
142 $dirmodels = array(
'/core/modules/printing/');
145 foreach ($dirmodels as $dir) {
146 if (file_exists(
dol_buildpath($dir, 0).$driver.
'.modules.php')) {
151 require_once $classfile;
152 $classname =
'printing_'.$driver;
153 $printer =
new $classname($db);
154 $langs->load($printer::LANGFILE);
158 foreach ($printer->conf as $key) {
159 switch ($key[
'type']) {
162 print
'<tr class="oddeven">';
163 print
'<td'.($key[
'required'] ?
' class=required' :
'').
'>'.$langs->trans($key[
'varname']).
'</td>';
164 print
'<td><input class="width100" type="'.(empty($key[
'type']) ?
'text' : $key[
'type']).
'" name="setupdriver['.$i.
'][value]" value="'.$conf->global->{$key[
'varname']}.
'"';
165 print isset($key[
'moreattributes']) ?
' '.$key[
'moreattributes'] :
'';
166 print
'><input type="hidden" name="setupdriver['.$i.
'][varname]" value="'.$key[
'varname'].
'"></td>';
167 print
'<td> '.($key[
'example'] !=
'' ? $langs->trans(
"Example").
' : '.$key[
'example'] :
'').
'</td>';
171 print
'<tr class="oddeven">';
172 print
'<td'.($key[
'required'] ?
' class=required' :
'').
'>';
173 if ($key[
'varname'] ==
'PRINTGCP_TOKEN_ACCESS') {
174 print $langs->trans(
"IsTokenGenerated");
176 print $langs->trans($key[
'varname']);
179 print
'<td>'.$langs->trans($key[
'info']).
'</td>';
182 if ($key[
'varname'] ==
'PRINTGCP_TOKEN_ACCESS') {
184 if (!empty($key[
'delete'])) {
185 print
'<a class="button" href="'.$key[
'delete'].
'">'.$langs->trans(
'DeleteAccess').
'</a><br><br>';
188 print
'<a class="button" href="'.$key[
'renew'].
'">'.$langs->trans(
'RequestAccess').
'</a><br><br>';
190 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>';
196 if ($key[
'enabled']) {
203 if ($key[
'varname'] ==
'PRINTGCP_TOKEN_ACCESS') {
205 print
'<tr class="oddeven">';
206 print
'<td>'.$langs->trans(
"Token").
'</td>';
207 print
'<td colspan="2">';
210 $storage =
new DoliStorage($db, $conf);
212 $tokenobj = $storage->retrieveAccessToken($OAUTH_SERVICENAME_GOOGLE);
216 if (is_object($tokenobj)) {
218 print $tokenobj->getAccessToken().
'<br>';
231 print $langs->trans(
'PleaseSelectaDriverfromList');
238 if (!empty($driver)) {
239 if ($submit_enabled) {
240 print
'<div class="center"><input type="submit" class="button" value="'.dol_escape_htmltag($langs->trans(
"Modify")).
'"></div>';
246 if ($mode ==
'config' && $user->admin) {
249 print $langs->trans(
"PrintingDesc").
"<br><br>\n";
251 print
'<table class="noborder centpercent">'.
"\n";
253 print
'<tr class="liste_titre">';
254 print
'<th>'.$langs->trans(
"Description").
'</th>';
255 print
'<th class="center">'.$langs->trans(
"Active").
'</th>';
256 print
'<th class="center">'.$langs->trans(
"Setup").
'</th>';
257 print
'<th class="center">'.$langs->trans(
"TargetedPrinter").
'</th>';
261 $result = $object->listDrivers($db, 10);
263 if (!empty($conf->modules_parts[
'printing'])) {
264 $dirmodels = array_merge(array(
'/core/modules/printing/'), (array) $conf->modules_parts[
'printing']);
266 $dirmodels = array(
'/core/modules/printing/');
269 foreach ($result as $tmpdriver) {
270 foreach ($dirmodels as $dir) {
271 if (file_exists(
dol_buildpath($dir, 0).$tmpdriver.
'.modules.php')) {
272 $classfile =
dol_buildpath($dir, 0).$tmpdriver.
'.modules.php';
276 require_once $classfile;
277 $classname =
'printing_'.$tmpdriver;
278 $printer =
new $classname($db);
279 $langs->load($printer::LANGFILE);
282 print
'<tr class="oddeven">';
283 print
'<td>'.img_picto(
'', $printer->picto).
' '.$langs->trans($printer->desc).
'</td>';
284 print
'<td class="center">';
285 if (!empty($conf->use_javascript_ajax)) {
288 if (empty($conf->global->{$printer->conf})) {
289 print
'<a href="'.$_SERVER[
'PHP_SELF'].
'?action=setvalue&token='.
newToken().
'&varname='.urlencode($printer->active).
'&value=1">'.
img_picto($langs->trans(
"Disabled"),
'off').
'</a>';
291 print
'<a href="'.$_SERVER[
'PHP_SELF'].
'?action=setvalue&token='.
newToken().
'&varname='.urlencode($printer->active).
'&value=0">'.
img_picto($langs->trans(
"Enabled"),
'on').
'</a>';
294 print
'<td class="center"><a href="'.$_SERVER[
'PHP_SELF'].
'?mode=setup&token='.
newToken().
'&driver='.urlencode($printer->name).
'">'.
img_picto(
'',
'setup').
'</a></td>';
295 print
'<td class="center"><a href="'.$_SERVER[
'PHP_SELF'].
'?mode=test&token='.
newToken().
'&driver='.urlencode($printer->name).
'">'.
img_picto(
'',
'setup').
'</a></td>';
304 if ($mode ==
'test' && $user->admin) {
307 print $langs->trans(
'PrintTestDesc'.$driver).
"<br><br>\n";
309 print
'<table class="noborder centpercent">';
310 if (!empty($driver)) {
311 if (!empty($conf->modules_parts[
'printing'])) {
312 $dirmodels = array_merge(array(
'/core/modules/printing/'), (array) $conf->modules_parts[
'printing']);
314 $dirmodels = array(
'/core/modules/printing/');
317 foreach ($dirmodels as $dir) {
318 if (file_exists(
dol_buildpath($dir, 0).$driver.
'.modules.php')) {
323 require_once $classfile;
324 $classname =
'printing_'.$driver;
325 $langs->load($driver);
326 $printer =
new $classname($db);
327 $langs->load($printer::LANGFILE);
329 if (count($printer->getlistAvailablePrinters())) {
330 if ($printer->listAvailablePrinters() == 0) {
331 print $printer->resprint;
336 print $langs->trans(
'PleaseConfigureDriverfromList');
339 print $langs->trans(
'PleaseSelectaDriverfromList');
346 if ($mode ==
'userconf' && $user->admin) {
349 print $langs->trans(
'PrintUserConfDesc'.$driver).
"<br><br>\n";
351 print
'<table class="noborder centpercent">';
352 print
'<tr class="liste_titre">';
353 print
'<th>'.$langs->trans(
"User").
'</th>';
354 print
'<th>'.$langs->trans(
"PrintModule").
'</th>';
355 print
'<th>'.$langs->trans(
"PrintDriver").
'</th>';
356 print
'<th>'.$langs->trans(
"Printer").
'</th>';
357 print
'<th>'.$langs->trans(
"PrinterLocation").
'</th>';
358 print
'<th>'.$langs->trans(
"PrinterId").
'</th>';
359 print
'<th>'.$langs->trans(
"NumberOfCopy").
'</th>';
360 print
'<th class="center">'.$langs->trans(
"Delete").
'</th>';
362 $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';
363 $resql = $db->query($sql);
364 while ($row = $db->fetch_array(
$resql)) {
365 print
'<tr class="oddeven">';
366 print
'<td>'.$row[
'login'].
'</td>';
367 print
'<td>'.$row[
'module'].
'</td>';
368 print
'<td>'.$row[
'driver'].
'</td>';
369 print
'<td>'.$row[
'printer_name'].
'</td>';
370 print
'<td>'.$row[
'printer_location'].
'</td>';
371 print
'<td>'.$row[
'printer_id'].
'</td>';
372 print
'<td>'.$row[
'copy'].
'</td>';
373 print
'<td class="center">'.img_picto($langs->trans(
"Delete"),
'delete').
'</td>';
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).
ajax_constantonoff($code, $input=array(), $entity=null, $revertonoff=0, $strict=0, $forcereload=0, $marginleftonlyshort=2, $forcenoajax=0, $setzeroinsteadofdel=0, $suffix='', $mode='', $morecss='')
On/off button for constant.
if(!defined('NOREQUIRESOC')) if(!defined('NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined('NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined('NOREQUIREAJAX')) llxHeader()
Empty header.
Parent class of emailing target selectors modules.
if(isModEnabled('facture') &&!empty($user->rights->facture->lire)) if((isModEnabled('fournisseur') &&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) && $user->hasRight("fournisseur", "facture", "lire"))||(isModEnabled('supplier_invoice') && $user->hasRight("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->hasRight("commande", "lire") &&empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) $resql
Social contributions to pay.
if($cancel &&! $id) if($action=='add' &&! $cancel) if($action=='delete') if($id) $form
Actions.
load_fiche_titre($titre, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limittoshow=0, $moretabssuffix='')
Show tabs of a record.
dol_print_error($db='', $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
dol_get_fiche_end($notab=0)
Return tab footer of a card.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='')
Set event messages in dol_events session object.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
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.
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.