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'));
38 $action =
GETPOST(
'action',
'aZ09');
39 $mode =
GETPOST(
'mode',
'alpha');
40 $value =
GETPOST(
'value',
'alpha', 0, null, null, 1);
41 $varname =
GETPOST(
'varname',
'alpha');
42 $driver =
GETPOST(
'driver',
'alpha');
44 if (!empty($driver)) $langs->load($driver);
46 if (!$mode) $mode =
'config';
48 $OAUTH_SERVICENAME_GOOGLE =
'Google';
55 if (($mode ==
'test' || $mode ==
'setup') && empty($driver))
58 header(
"Location: ".
$_SERVER[
'PHP_SELF'].
'?mode=config');
62 if ($action ==
'setconst' && $user->admin)
66 foreach ($_POST[
'setupdriver'] as $setupconst) {
68 $result =
dolibarr_set_const($db, $setupconst[
'varname'], $setupconst[
'value'],
'chaine', 0,
'', $conf->entity);
69 if (!$result > 0) $error++;
82 if ($action ==
'setvalue' && $user->admin)
87 if (!$result > 0) $error++;
104 $form =
new Form($db);
106 llxHeader(
'', $langs->trans(
"PrintingSetup"));
108 $linkback =
'<a href="'.DOL_URL_ROOT.
'/admin/modules.php?restore_lastsearch_values=1">'.$langs->trans(
"BackToModuleList").
'</a>';
113 if ($mode ==
'setup' && $user->admin)
115 print '<form method="post" action="'.$_SERVER[
"PHP_SELF"].
'?mode=setup&driver='.$driver.
'" autocomplete="off">';
116 print '<input type="hidden" name="token" value="'.newToken().
'">';
117 print '<input type="hidden" name="action" value="setconst">';
121 print $langs->trans(
"PrintingDriverDesc".$driver).
"<br><br>\n";
123 print '<table class="noborder centpercent">'.
"\n";
124 print '<tr class="liste_titre">';
125 print '<th>'.$langs->trans(
"Parameters").
'</th>';
126 print '<th>'.$langs->trans(
"Value").
'</th>';
127 print '<th> </th>';
131 if (!empty($driver)) {
132 $dirmodels = array_merge(array(
'/core/modules/printing/'), (array) $conf->modules_parts[
'printing']);
133 foreach ($dirmodels as $dir) {
134 if (file_exists(
dol_buildpath($dir, 0).$driver.
'.modules.php')) {
139 require_once $classfile;
140 $classname =
'printing_'.$driver;
141 $printer =
new $classname($db);
142 $langs->load($printer::LANGFILE);
146 foreach ($printer->conf as $key)
148 switch ($key[
'type']) {
151 print '<tr class="oddeven">';
152 print '<td'.($key[
'required'] ?
' class=required' :
'').
'>'.$langs->trans($key[
'varname']).
'</td>';
153 print '<td><input size="32" type="'.(empty($key[
'type']) ?
'text' : $key[
'type']).
'" name="setupdriver['.$i.
'][value]" value="'.$conf->global->{$key[
'varname']}.
'"';
154 print isset($key[
'moreattributes']) ?
' '.$key[
'moreattributes'] :
'';
155 print '><input type="hidden" name="setupdriver['.$i.
'][varname]" value="'.$key[
'varname'].
'"></td>';
156 print '<td> '.($key[
'example'] !=
'' ? $langs->trans(
"Example").
' : '.$key[
'example'] :
'').
'</td>';
160 print '<tr class="oddeven">';
161 print '<td'.($key[
'required'] ?
' class=required' :
'').
'>';
162 if ($key[
'varname'] ==
'PRINTGCP_TOKEN_ACCESS')
164 print $langs->trans(
"IsTokenGenerated");
166 print $langs->trans($key[
'varname']);
169 print '<td>'.$langs->trans($key[
'info']).
'</td>';
172 if ($key[
'varname'] ==
'PRINTGCP_TOKEN_ACCESS')
175 if (!empty($key[
'delete']))
print '<a class="button" href="'.$key[
'delete'].
'">'.$langs->trans(
'DeleteAccess').
'</a><br><br>';
177 print '<a class="button" href="'.$key[
'renew'].
'">'.$langs->trans(
'RequestAccess').
'</a><br><br>';
179 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>';
185 if ($key[
'enabled']) $submit_enabled = 1;
190 if ($key[
'varname'] ==
'PRINTGCP_TOKEN_ACCESS')
193 print '<tr class="oddeven">';
194 print '<td>'.$langs->trans(
"Token").
'</td>';
195 print '<td colspan="2">';
198 $storage =
new DoliStorage($db, $conf);
200 $tokenobj = $storage->retrieveAccessToken($OAUTH_SERVICENAME_GOOGLE);
205 if (is_object($tokenobj))
208 print $tokenobj->getAccessToken().
'<br>';
221 print $langs->trans(
'PleaseSelectaDriverfromList');
230 if ($submit_enabled) {
231 print '<div class="center"><input type="submit" class="button" value="'.dol_escape_htmltag($langs->trans(
"Modify")).
'"></div>';
237 if ($mode ==
'config' && $user->admin)
241 print $langs->trans(
"PrintingDesc").
"<br><br>\n";
243 print '<table class="noborder centpercent">'.
"\n";
245 print '<tr class="liste_titre">';
246 print '<th>'.$langs->trans(
"Description").
'</th>';
247 print '<th class="center">'.$langs->trans(
"Active").
'</th>';
248 print '<th class="center">'.$langs->trans(
"Setup").
'</th>';
249 print '<th class="center">'.$langs->trans(
"TargetedPrinter").
'</th>';
253 $result = $object->listDrivers($db, 10);
254 $dirmodels = array_merge(array(
'/core/modules/printing/'), (array) $conf->modules_parts[
'printing']);
255 foreach ($result as $driver) {
256 foreach ($dirmodels as $dir) {
257 if (file_exists(
dol_buildpath($dir, 0).$driver.
'.modules.php')) {
262 require_once $classfile;
263 $classname =
'printing_'.$driver;
264 $printer =
new $classname($db);
265 $langs->load($printer::LANGFILE);
268 print '<tr class="oddeven">';
269 print '<td>'.img_picto(
'', $printer->picto).
' '.$langs->trans($printer->desc).
'</td>';
270 print '<td class="center">';
271 if (!empty($conf->use_javascript_ajax)) {
274 if (empty($conf->global->{$printer->conf})) {
275 print '<a href="'.$_SERVER[
'PHP_SELF'].
'?action=setvalue&token='.
newToken().
'&varname='.$printer->active.
'&value=1">'.
img_picto($langs->trans(
"Disabled"),
'off').
'</a>';
277 print '<a href="'.$_SERVER[
'PHP_SELF'].
'?action=setvalue&token='.
newToken().
'&varname='.$printer->active.
'&value=0">'.
img_picto($langs->trans(
"Enabled"),
'on').
'</a>';
280 print '<td class="center"><a href="'.$_SERVER[
'PHP_SELF'].
'?mode=setup&driver='.$printer->name.
'">'.
img_picto(
'',
'setup').
'</a></td>';
281 print '<td class="center"><a href="'.$_SERVER[
'PHP_SELF'].
'?mode=test&driver='.$printer->name.
'">'.
img_picto(
'',
'setup').
'</a></td>';
290 if ($mode ==
'test' && $user->admin)
294 print $langs->trans(
'PrintTestDesc'.$driver).
"<br><br>\n";
296 print '<table class="noborder centpercent">';
297 if (!empty($driver)) {
298 $dirmodels = array_merge(array(
'/core/modules/printing/'), (array) $conf->modules_parts[
'printing']);
299 foreach ($dirmodels as $dir) {
300 if (file_exists(
dol_buildpath($dir, 0).$driver.
'.modules.php')) {
305 require_once $classfile;
306 $classname =
'printing_'.$driver;
307 $langs->load($driver);
308 $printer =
new $classname($db);
309 $langs->load($printer::LANGFILE);
311 if (count($printer->getlistAvailablePrinters())) {
312 if ($printer->listAvailablePrinters() == 0) {
313 print $printer->resprint;
318 print $langs->trans(
'PleaseConfigureDriverfromList');
321 print $langs->trans(
'PleaseSelectaDriverfromList');
328 if ($mode ==
'userconf' && $user->admin)
332 print $langs->trans(
'PrintUserConfDesc'.$driver).
"<br><br>\n";
334 print '<table class="noborder centpercent">';
335 print '<tr class="liste_titre">';
336 print '<th>'.$langs->trans(
"User").
'</th>';
337 print '<th>'.$langs->trans(
"PrintModule").
'</th>';
338 print '<th>'.$langs->trans(
"PrintDriver").
'</th>';
339 print '<th>'.$langs->trans(
"Printer").
'</th>';
340 print '<th>'.$langs->trans(
"PrinterLocation").
'</th>';
341 print '<th>'.$langs->trans(
"PrinterId").
'</th>';
342 print '<th>'.$langs->trans(
"NumberOfCopy").
'</th>';
343 print '<th class="center">'.$langs->trans(
"Delete").
'</th>';
345 $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';
346 $resql = $db->query($sql);
347 while ($row = $db->fetch_array(
$resql)) {
348 print '<tr class="oddeven">';
349 print '<td>'.$row[
'login'].
'</td>';
350 print '<td>'.$row[
'module'].
'</td>';
351 print '<td>'.$row[
'driver'].
'</td>';
352 print '<td>'.$row[
'printer_name'].
'</td>';
353 print '<td>'.$row[
'printer_location'].
'</td>';
354 print '<td>'.$row[
'printer_id'].
'</td>';
355 print '<td>'.$row[
'copy'].
'</td>';
356 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.
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).
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)
ajax_constantonoff($code, $input=array(), $entity=null, $revertonoff=0, $strict=0, $forcereload=0, $marginleftonlyshort=2, $forcenoajax=0)
On/off button for constant.
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 ...
print $_SERVER["PHP_SELF"]
Edit parameters.
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.
print
Draft customers invoices.
if(!empty($conf->facture->enabled)&&$user->rights->facture->lire) if((!empty($conf->fournisseur->enabled)&&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)||!empty($conf->supplier_invoice->enabled))&&$user->rights->fournisseur->facture->lire) if(!empty($conf->don->enabled)&&$user->rights->don->lire) if(!empty($conf->tax->enabled)&&$user->rights->tax->charges->lire) if(!empty($conf->facture->enabled)&&!empty($conf->commande->enabled)&&$user->rights->commande->lire &&empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) if(!empty($conf->facture->enabled)&&$user->rights->facture->lire) if((!empty($conf->fournisseur->enabled)&&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)||!empty($conf->supplier_invoice->enabled))&&$user->rights->fournisseur->facture->lire) $resql
Social contributions to pay.
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.