FIX showing the receipt for print will generate a unalterable log

This commit is contained in:
Laurent Destailleur 2024-10-28 21:23:54 +01:00
parent 838316418f
commit abf5323484
4 changed files with 37 additions and 8 deletions

View File

@ -60,7 +60,7 @@ if (empty($action)) {
exit;
}
if ($element === 'facture') {
if ($element === 'facture') { // Test on permission done in top of page
require_once DOL_DOCUMENT_ROOT.'/blockedlog/class/blockedlog.class.php';
require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php';

View File

@ -3929,7 +3929,7 @@ if (!function_exists("llxFooter")) {
print '<script src="'.DOL_URL_ROOT.'/core/js/lib_foot.js.php?lang='.$langs->defaultlang.($ext ? '&'.$ext : '').'"></script>'."\n";
}
// Wrapper to add log when clicking on download or preview
// JS wrapper to add log when clicking on download or preview
if (isModEnabled('blockedlog') && is_object($object) && !empty($object->id) && $object->id > 0) {
if (in_array($object->element, array('facture')) && $object->statut > 0) { // Restrict for the moment to element 'facture'
print "\n<!-- JS CODE TO ENABLE log when making a download or a preview of a document -->\n";

View File

@ -68,7 +68,7 @@ if (!$user->hasRight('takepos', 'run')) {
* View
*/
top_httphead('text/html', 1);
top_htmlhead('', '', 1);
if ($place > 0) {
$sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."facture where ref='(PROV-POS".$db->escape($_SESSION["takeposterminal"]."-".$place).")'";
@ -81,6 +81,25 @@ if ($place > 0) {
$object = new Facture($db);
$object->fetch($facid);
// Record entry in blocked logs
// DOL_DOCUMENT_ROOT.'/blockedlog/ajax/block-add.php?id='.$object->id.'&element='.$object->element.'&action=DOC_PREVIEW&token='.newToken();
print "
<script>
jQuery(document).ready(function () {
console.log('Call /blockedlog/ajax/block-add on output of receipt.php');
$.post('".DOL_URL_ROOT."/blockedlog/ajax/block-add.php'
, {
id: ".((int) $object->id)."
, element: '".dol_escape_js($object->element)."'
, action: 'DOC_PREVIEW'
, token: '".currentToken()."'
}
);
});
</script>";
// Call to external receipt modules if exist
$parameters = array();
$hookmanager->initHooks(array('takeposfrontend'));
@ -103,6 +122,16 @@ if (!empty($hookmanager->resPrint)) {
.left {
text-align: left;
}
.centpercent {
width: 100%;
}
@media only screen and (min-width: 1024px)
{
body {
margin-left: 50px;
margin-right: 50px;
}
}
</style>
<center>
<div style="font-size: 1.5em">
@ -132,7 +161,7 @@ print $langs->trans('Date')." ".dol_print_date($object->date, 'day').'<br>';
if (getDolGlobalString('TAKEPOS_RECEIPT_NAME')) {
print getDolGlobalString('TAKEPOS_RECEIPT_NAME') . " ";
}
if ($object->statut == Facture::STATUS_DRAFT) {
if ($object->status == Facture::STATUS_DRAFT) {
print str_replace(")", "", str_replace("-", " ".$langs->trans('Place')." ", str_replace("(PROV-POS", $langs->trans("Terminal")." ", $object->ref)));
} else {
print $object->ref;
@ -155,7 +184,7 @@ if (getDolGlobalString('TAKEPOS_SHOW_DATE_OF_PRINING')) {
</p>
<br>
<table width="100%" style="border-top-style: double;">
<table class="centpercent" style="border-top-style: double;">
<thead>
<tr>
<th class="center"><?php print $langs->trans("Label"); ?></th>
@ -194,7 +223,7 @@ if (getDolGlobalString('TAKEPOS_SHOW_DATE_OF_PRINING')) {
<?php if (!empty($line->product_label)) {
echo $line->product_label;
} else {
echo $line->description;
echo $line->desc;
} ?>
</td>
<td class="right"><?php echo $line->qty; ?></td>
@ -219,7 +248,7 @@ if (getDolGlobalString('TAKEPOS_SHOW_DATE_OF_PRINING')) {
</tbody>
</table>
<br>
<table class="right">
<table class="right centpercent">
<tr>
<th class="right"><?php if ($gift != 1) {
echo $langs->trans("TotalHT");

View File

@ -372,7 +372,7 @@ print 'fontsizesmaller='.$fontsizesmaller."\n";
print 'topMenuFontSize='.$topMenuFontSize."\n";
print 'toolTipBgColor='.$toolTipBgColor."\n";
print 'toolTipFontColor='.$toolTipFontColor."\n";
print 'conf->global->THEME_SATURATE_RATIO='.(!getDolGlobalString('THEME_SATURATE_RATIO') ? '' : $conf->global->THEME_SATURATE_RATIO)." (must be between 0 and 1)\n";
print 'conf->global->THEME_SATURATE_RATIO='.getDolGlobalString('THEME_SATURATE_RATIO')." (must be between 0 and 1)\n";
print '*/'."\n";