diff --git a/htdocs/blockedlog/ajax/block-add.php b/htdocs/blockedlog/ajax/block-add.php new file mode 100644 index 0000000000000000000000000000000000000000..247b01186feb2c21fe9f7adaaf41b6c717b3d46d --- /dev/null +++ b/htdocs/blockedlog/ajax/block-add.php @@ -0,0 +1,19 @@ +<?php + + require '../../main.inc.php'; + require_once DOL_DOCUMENT_ROOT.'/blockedlog/class/blockedlog.class.php'; + + $id = GETPOST('id','int'); + $element = GETPOST('element','alpha'); + $action = GETPOST('action','alpha'); + + if($element === 'facture') { + dol_include_once('/compta/facture/class/facture.class.php'); + + $facture = new Facture($db); + if($facture->fetch($id)>0) { + $facture->call_trigger($action, $user); + } + + } + \ No newline at end of file diff --git a/htdocs/compta/facture/card.php b/htdocs/compta/facture/card.php index 223acb91fb35b448bbbb5f1fa5782dafd3e5737d..ce16d6b9931ab31a8e10ac30932739ea8119fe54 100644 --- a/htdocs/compta/facture/card.php +++ b/htdocs/compta/facture/card.php @@ -4247,6 +4247,37 @@ else if ($id > 0 || ! empty($ref)) $delallowed = $user->rights->facture->supprimer; print $formfile->showdocuments('facture', $filename, $filedir, $urlsource, $genallowed, $delallowed, $object->modelpdf, 1, 0, 0, 28, 0, '', '', '', $soc->default_lang); + + if(!empty($conf->blockedlog->enabled) && $object->statut>0) { + ?> + <script type="text/javascript"> + + $(document).ready(function() { + $('a.documentpreview').click(function() { + $.post("<?php echo DOL_URL_ROOT."/blockedlog/ajax/block-add.php" ?>" + , { + id:<?php echo $object->id; ?> + , element:"<?php echo $object->element ?>" + , action:"PREVIEW_BILL" + } + ); + }); + $('a.documentdownload').click(function() { + $.post("<?php echo DOL_URL_ROOT."/blockedlog/ajax/block-add.php" ?>" + , { + id:<?php echo $object->id; ?> + , element:"<?php echo $object->element ?>" + , action:"DOWNLOAD_BILL" + } + ); + }); + }); + + </script> + <?php + } + + $somethingshown = $formfile->numoffiles; // Show links to link elements diff --git a/htdocs/core/class/html.formfile.class.php b/htdocs/core/class/html.formfile.class.php index 89cf70951ad8b2abef8987d50c84d9df10bd2dd0..44a9079479004287d84e3362f9e0ee6afd84c539 100644 --- a/htdocs/core/class/html.formfile.class.php +++ b/htdocs/core/class/html.formfile.class.php @@ -712,7 +712,7 @@ class FormFile $out.= '<td class="tdoverflowmax300">'; $tmp = $this->showPreview($file,$modulepart,$relativepath,0,$param); $out.= ($tmp?$tmp.' ':''); - $out.= '<a href="'.$documenturl.'?modulepart='.$modulepart.'&file='.urlencode($relativepath).($param?'&'.$param:'').'"'; + $out.= '<a class="documentdownload" href="'.$documenturl.'?modulepart='.$modulepart.'&file='.urlencode($relativepath).($param?'&'.$param:'').'"'; $mime=dol_mimetype($relativepath,'',0); if (preg_match('/text/',$mime)) $out.= ' target="_blank"'; $out.= ' target="_blank">'; diff --git a/htdocs/core/triggers/interface_50_modBlockedlog_ActionsBlockedLog.class.php b/htdocs/core/triggers/interface_50_modBlockedlog_ActionsBlockedLog.class.php index 461a277dfd4e41cf8738d311700e2ae87c9a63f5..004c4eecd7802b902ed87e3913d76829af38fcbb 100644 --- a/htdocs/core/triggers/interface_50_modBlockedlog_ActionsBlockedLog.class.php +++ b/htdocs/core/triggers/interface_50_modBlockedlog_ActionsBlockedLog.class.php @@ -51,7 +51,8 @@ class InterfaceActionsBlockedLog extends DolibarrTriggers return 0; } - if($action==='BILL_VALIDATE' || $action === 'BILL_PAYED' || $action==='BILL_UNPAYED' || $action === 'BILL_SENTBYMAIL') { + if($action==='BILL_VALIDATE' || $action === 'BILL_PAYED' || $action==='BILL_UNPAYED' + || $action === 'BILL_SENTBYMAIL' || $action === 'DOWNLOAD_BILL' || $action === 'PREVIEW_BILL') { $amounts= (double) $object->total_ttc; } else if($action === 'PAYMENT_CUSTOMER_CREATE' || $action === 'PAYMENT_ADD_TO_BANK') { diff --git a/htdocs/langs/en_US/blockedlog.lang b/htdocs/langs/en_US/blockedlog.lang index 7e64bfad17f856332b50e02a35089787d1cbd1f7..fcad52508bd562044d109b326a757f506aa5282b 100644 --- a/htdocs/langs/en_US/blockedlog.lang +++ b/htdocs/langs/en_US/blockedlog.lang @@ -18,4 +18,6 @@ logBILL_VALIDATE=Customer bill set valid from draft logBILL_SENTBYMAIL=Customer bill send by mail BlockedlogInfoDialog=Log Details Fingerprint=Fingerprint -DownloadLogCSV=Download fingerprints CSV \ No newline at end of file +DownloadLogCSV=Download fingerprints CSV +logPREVIEW_BILL=Preview of a validated customer bill in order to print or download +logDOWNLOAD_BILL=Download of a validated customer bill in order to print or send \ No newline at end of file