27include_once DOL_DOCUMENT_ROOT.
'/blockedlog/versionmod.inc.php';
37 $versionbadge = constant(
'DOLCERT_VERSION');
40 if (!constant(
'CERTIF_LNE')) {
44 if (constant(
'DOLCERT_NAME') !=
'BlockedLog') {
45 $versionbadge = constant(
'DOLCERT_NAME').
'-'.$versionbadge;
62 $langs->load(
"blockedlog");
64 require_once DOL_DOCUMENT_ROOT.
'/blockedlog/class/blockedlog.class.php';
67 $param .= ($withtabsetup?
"?withtab=".$withtabsetup :
"");
68 $param .= (
GETPOST(
'origin') ? ($param ?
'&' :
'?').
'origin='.
GETPOST(
'origin') :
'');
74 $head[$h][0] = DOL_URL_ROOT.
"/blockedlog/admin/registration.php".$param;
75 $head[$h][1] = $langs->trans(
"UserRegistration");
76 $head[$h][2] =
'registration';
82 $head[$h][0] = DOL_URL_ROOT.
"/blockedlog/admin/blockedlog_list.php".$param;
83 $head[$h][1] = $langs->trans(
"BrowseBlockedLog");
84 if ($b->alreadyUsed()) {
85 $head[$h][1] .= (!
getDolGlobalString(
'MAIN_OPTIMIZEFORTEXTBROWSER') ?
'<span class="badge marginleftonlyshort">...</span>' :
'');
87 $head[$h][2] =
'fingerprints';
91 $head[$h][0] = DOL_URL_ROOT.
"/blockedlog/admin/blockedlog_archives.php".$param;
92 $head[$h][1] = $langs->trans(
"Archives");
96 require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
97 require_once DOL_DOCUMENT_ROOT.
'/core/class/link.class.php';
98 $nbFiles = count(
dol_dir_list($upload_dir,
'files', 0,
'',
'(\.meta|_preview.*\.png)$'));
100 if (($nbFiles + $nbLinks) > 0) {
101 $head[$h][1] .=
'<span class="badge marginleftonlyshort">'.($nbFiles + $nbLinks).
'</span>';
103 $head[$h][2] =
'archives';
107 $head[$h][0] = DOL_URL_ROOT.
"/blockedlog/admin/blockedlog_control.php".$param;
108 $head[$h][1] = $langs->trans(
"OtherControl");
109 $head[$h][2] =
'control';
113 if (
$mysoc->country_code ==
'FR') {
114 $head[$h][0] = DOL_URL_ROOT.
"/blockedlog/admin/documentation.php".$param;
115 $head[$h][1] = $langs->trans(
"Documentation");
116 $head[$h][2] =
'documentation';
121 $head[$h][0] = DOL_URL_ROOT.
"/blockedlog/admin/blockedlog.php".$param;
122 $head[$h][1] = $langs->trans(
"TechnicalInformation");
123 $head[$h][2] =
'technicalinfo';
154 $companycountrycode =
$mysoc->country_code;
159 if (empty($companyname) || empty($companycountrycode) || empty($companyidprof1) || empty($companyidprof2) || empty($companyemail)) {
195 return dol_hash(
'dolibarr'.
$conf->file->instance_unique_id.($conf->entity > 1 ?
$conf->entity :
''), $algo, 1);
215 if (defined(
'CERTIF_LNE') && (
int) constant(
'CERTIF_LNE') === 2) {
216 return 'CERTIF_LNE_IS_2';
219 if (!$ignoredev && preg_match(
'/\-/', DOL_VERSION)) {
222 if (
$mysoc->country_code !=
'FR') {
225 if (!defined(
'CERTIF_LNE') || (
int) constant(
'CERTIF_LNE') === 0) {
233 return ($ignoredev ?
'' :
'NOT_BETA+').
'FR+CERTIF_LNE_IS_1'.($ignoremodule ?
'' :
'+MODENABLED');
250 if (defined(
'CERTIF_LNE') && (
int) constant(
'CERTIF_LNE') === 2
251 && ($blockedlogmodulealreadydone ||
isModEnabled(
'blockedlog'))
255 if (defined(
'CERTIF_LNE') && (
int) constant(
'CERTIF_LNE') === 1
256 && ($blockedlogmodulealreadydone ||
isModEnabled(
'blockedlog'))
279 if (array_key_exists(
'isblockedlogused',
$conf->cache)) {
280 return $conf->cache[
'isblockedlogused'.$ignoresystem];
283 $sql =
"SELECT rowid FROM ".MAIN_DB_PREFIX.
"blockedlog";
284 $sql .=
" WHERE entity = ".((int)
$conf->entity);
286 $sql .=
" AND action NOT IN ('MODULE_SET', 'MODULE_RESET')";
288 $sql .=
$db->plimit(1);
290 $resql =
$db->query($sql);
291 if ($resql !==
false) {
292 $obj =
$db->fetch_object($resql);
300 $conf->cache[
'isblockedlogused'.$ignoresystem] = $result;
303 dol_syslog(
"isBlockedLogUsed: ignoresystem=".$ignoresystem.
" returns ".(
string) $result);
324 if (in_array($seller->country_code, array(
'FR'))) {
325 $outputlangs->load(
"blockedlog");
326 $blockedlog_mention =
'';
329 if ($isalne ==
'CERTIF_LNE_IS_2') {
330 $blockedlog_mention = $outputlangs->transnoentitiesnoconv(
"InvoiceGeneratedWithLNECandidatePOSSystem");
332 $blockedlog_mention = $outputlangs->transnoentitiesnoconv(
"InvoiceGeneratedWithLNECertifiedPOSSystem");
335 if ($blockedlog_mention) {
336 $pdf->SetFont(
'',
'', $default_font_size - 2);
337 $pdf->SetXY($pdftemplate->marge_gauche, $posy);
338 $pdf->MultiCell(100, 3, $blockedlog_mention, 0,
'L',
false);
339 $posy = $pdf->GetY();
362 if ($block->action ==
'BILL_VALIDATE') {
363 $total_ht = $block->object_data->total_ht;
364 $total_vat = $block->object_data->total_tva;
365 $total_ttc = $block->object_data->total_ttc;
368 if (!isset($totalamount[$block->action][$block->module_source])) {
369 $totalhtamount[$block->action][$block->module_source] = 0;
370 $totalvatamount[$block->action][$block->module_source] = 0;
371 $totalamount[$block->action][$block->module_source] = 0;
376 if (empty($refinvoicefound[$block->ref_object])) {
377 $totalhtamount[$block->action][$block->module_source] += $total_ht;
378 $totalvatamount[$block->action][$block->module_source] += $total_vat;
379 $totalamount[$block->action][$block->module_source] += $total_ttc;
381 $refinvoicefound[$block->ref_object] = 1;
382 } elseif ($block->action ==
'PAYMENT_CUSTOMER_CREATE' || $block->action ==
'PAYMENT_CUSTOMER_DELETE') {
383 $total_ht = $block->object_data->amount;
385 $total_ttc = $block->object_data->amount;
388 $actionkey =
'PAYMENT_CUSTOMER';
391 if (!isset($totalamount[$actionkey][$block->module_source])) {
392 $totalhtamount[$actionkey][$block->module_source] = 0;
393 $totalvatamount[$actionkey][$block->module_source] = 0;
394 $totalamount[$actionkey][$block->module_source] = 0;
397 $totalhtamount[$actionkey][$block->module_source] += $total_ht;
398 $totalvatamount[$actionkey][$block->module_source] += $total_vat;
399 $totalamount[$actionkey][$block->module_source] += $total_ttc;
401 $total_ttc = $block->amounts;
421 $obfuscationkey =
'ERROR';
423 if (empty($idprof1)) {
424 dol_syslog(
"callApiToGetObfuscationKey was called with empty idprof1", LOG_DEBUG);
425 return 'ERROR callApiToGetObfuscationKey was called with empty idprof1';
429 $url_for_ping =
getDolGlobalString(
'MAIN_URL_FOR_PING',
"https://ping.dolibarr.org/");
434 $t = microtime(
true);
435 $micro = sprintf(
"%06d", (
int) (($t - floor($t)) * 1000000));
438 $data .=
'hash_algo=dol_hash-'.urlencode($algo);
439 $data .=
'&hash_unique_id='.urlencode($hash_unique_id);
440 $data .=
'&action=dolibarrgetkeyobfuscation';
442 $data .=
'&version='.(float) DOL_VERSION;
443 $data .=
'&version_full='.urlencode(DOL_VERSION);
447 $data .=
'&entity='.(int)
$conf->entity;
452 $addheaders = array();
454 $timeoutresponse = 3;
459 include_once DOL_DOCUMENT_ROOT.
'/core/lib/geturl.lib.php';
461 $tmpresult =
getURLContent($url_for_ping,
'POST', $data, 1, $addheaders, array(
'https'), 0, -1, $timeoutconnect, $timeoutresponse, array());
465 if ($tmpresult[
'http_code'] == 0 && !empty($tmpresult[
'curl_error_msg'])) {
466 $logerrormessage =
'Error: '.$tmpresult[
'curl_error_msg'];
467 $obfuscationkey .=
' '.$tmpresult[
'curl_error_msg'];
468 dol_syslog(
"callApiToGetObfuscationKey result error when getting obfuscation key: ".$logerrormessage, LOG_WARNING);
469 dol_syslog(
"callApiToGetObfuscationKey result error when getting obfuscation key: ".$logerrormessage, LOG_WARNING, 0,
'_dolibarrgetkeyobfuscation');
470 } elseif ($tmpresult[
'http_code'] != 200) {
471 $logerrormessage =
'Error: '.$tmpresult[
'http_code'].
' '.$tmpresult[
'content'];
472 $obfuscationkey .=
' '.$tmpresult[
'http_code'].
' '.$tmpresult[
'content'];
473 dol_syslog(
"callApiToGetObfuscationKey result error when getting obfuscation key: ".$logerrormessage, LOG_WARNING);
474 dol_syslog(
"callApiToGetObfuscationKey result error when getting obfuscation key: ".$logerrormessage, LOG_WARNING, 0,
'_dolibarrgetkeyobfuscation');
477 if (preg_match(
'/(DOLOBFUSCKEY.*)/', $tmpresult[
'content'], $reg)) {
478 $obfuscationkey = $reg[1];
479 dol_syslog(
"callApiToGetObfuscationKey we got the remote obfuscation key", LOG_DEBUG);
480 dol_syslog(
"callApiToGetObfuscationKey we got the remote obfuscation key", LOG_DEBUG, 0,
'_dolibarrgetkeyobfuscation');
482 $obfuscationkey .=
' '.$tmpresult[
'content'];
483 dol_syslog(
"callApiToGetObfuscationKey result error when getting obfuscation key: ".$tmpresult[
'content'], LOG_WARNING);
484 dol_syslog(
"callApiToGetObfuscationKey result error when getting obfuscation key: ".$tmpresult[
'content'], LOG_WARNING, 0,
'_dolibarrgetkeyobfuscation');
488 $obfuscationkey .=
' '.$e->getMessage();
489 dol_syslog(
"callApiToGetObfuscationKey result error ".$e->getMessage(), LOG_ERR);
490 dol_syslog(
"callApiToGetObfuscationKey result error ".$e->getMessage(), LOG_ERR, 0,
'_dolibarrgetkeyobfuscation');
493 return $obfuscationkey;
625 if (
$object->status > $object::STATUS_DRAFT) {
626 $unalterablelogid =
'UNDEFINED';
628 $sql =
"SELECT signature FROM ".MAIN_DB_PREFIX.
"blockedlog";
629 $sql .=
" WHERE action = 'BILL_VALIDATE' AND element = 'facture' AND ref_object = '".$db->escape(
$object->ref).
"'";
630 $sql .=
$db->order(
'rowid',
'DESC');
631 $sql .=
$db->plimit(1);
633 $resql =
$db->query($sql);
635 $obj =
$db->fetch_object($resql);
637 $unalterablelogid = $obj->signature;
641 if ($unalterablelogid !=
'UNDEFINED') {
642 $pdf->SetXY($posx, $posy);
643 $pdf->SetTextColor(0, 0, 60);
644 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"SignatureID").
" : ".
dol_trunc(strtoupper($unalterablelogid), 10),
'',
'R');
648 $isADuplicata = (
$object->pos_print_counter >= 2);
650 $pdf->SetXY($posx, $posy);
651 $pdf->SetTextColor(0, 0, 60);
652 $pdf->MultiCell($w, 3,
'*** '.$outputlangs->trans(
"DUPLICATA").(getDolGlobalString(
'TAKEPOS_SHOW_PRINT_COUNTER_ON_RECEIPT') ?
' (no '.($object->pos_print_counter - 1).
')' :
'').
' ***',
'',
'R');
657 if (
$object->status == $object::STATUS_DRAFT) {
658 $pdf->SetXY($posx, $posy);
659 $pdf->SetTextColor(0, 0, 60);
660 $pdf->MultiCell($w, 3,
'*** '.strtoupper($outputlangs->trans(
"TemporaryReceipt")).
' ***',
'',
'R');
677 include_once DOL_DOCUMENT_ROOT.
'/blockedlog/class/blockedlog.class.php';
682 $listofentities = array();
683 $sql =
"SELECT DISTINCT entity FROM ".MAIN_DB_PREFIX.
"blockedlog";
684 $resql =
$db->query($sql);
686 while ($obj =
$db->fetch_object($resql)) {
687 $listofentities[] = $obj->entity;
690 print
'<tr class="trforrunsql"><td colspan="4">';
691 print
'<b>'.$langs->trans(
'InitEndFlagFile').
"</b>:\n";
692 print
'Error: Failed to get list of entities in blockedlog table';
697 foreach ($listofentities as $entity) {
698 print
'<tr class="trforrunsql"><td colspan="4">';
699 print
'<b>'.$langs->trans(
'InitEndFlagFile').
" (entity = ".$entity.
")</b>:\n";
702 $conf->setEntityValues(
$db, $entity);
707 $sql =
"SELECT MAX(rowid) as maxid FROM ".MAIN_DB_PREFIX.
"blockedlog WHERE entity = ".((int) $entity);
708 $resql =
$db->query($sql);
710 $obj =
$db->fetch_object($resql);
712 $maxid = $obj->maxid;
715 print
'Error: Failed to get max id of blockedlog table';
720 $blocklog_static->fetch($maxid);
722 $lockfile = $blocklog_static->getEndOfChainFlagFile();
725 $stringtowrite =
'BLOCKEDLOGHEAD '.$blocklog_static->id.
" ".
dol_print_date($blocklog_static->date_creation,
'dayhourrfc',
'gmt').
" ".(
string) $blocklog_static->signature;
728 $remoteobfuscationkey = $blocklog_static->getObfuscationKey();
729 if (empty($remoteobfuscationkey)) {
730 print
"Error: Failed to get the remote obfuscation key. We can't record the end of chain flag file so we abort the transaction.";
735 $stringtowriteencoded =
dolEncrypt($stringtowrite, $remoteobfuscationkey,
'',
'',
'dolobfuscationv1-'.
$mysoc->idprof1.
'-'.$blocklog_static->id);
737 $stringtowriteencoded =
dolEncrypt($stringtowrite,
'',
'',
'',
'dolcrypt-'.
$mysoc->idprof1.
'-'.$blocklog_static->id);
741 if (defined(
'BLOCKEDLOG_END_FLAG_IN_A_FILE')) {
742 $lockhandle = fopen($lockfile,
'w+');
744 if (fwrite($lockhandle, $stringtowriteencoded.
"\n") ===
false) {
745 print
"Cannot write to the blockedlog .end file ".$lockfile;
753 print
"Cannot open for writing the blockedlog .end file ".$lockfile;
758 $sql =
"DELETE FROM ".MAIN_DB_PREFIX.
"const";
759 $sql .=
" WHERE name = '".$db->escape(basename($lockfile)).
"' AND entity = ".((int)
$conf->entity);
760 $resql =
$db->query($sql);
762 $sql =
"INSERT INTO ".MAIN_DB_PREFIX.
"const(name, value, type, visible, note, entity)";
763 $sql .=
" VALUES('".$db->escape(basename($lockfile)).
"', '".
$db->escape($stringtowriteencoded).
"', 'chaine', 0, 'Blockedlog end of chain flag', ".((int)
$conf->entity).
")";
764 $resql =
$db->query($sql);
766 print
"Cannot open for writing the blockedlog .end file ".basename($lockfile);
772 print $langs->trans(
"Done");
if(! $sortfield) if(! $sortorder) $object
migrate_blockedlog_add_end_file()
Migrate an old database to add the .end flag.
sumAmountsForUnalterableEvent($block, &$refinvoicefound, &$totalhtamount, &$totalvatamount, &$totalamount, &$total_ht, &$total_vat, &$total_ttc)
sumAmountsForUnalterableEvent
getBlockedLogVersionToShow()
Define head array for tabs of blockedlog tools setup pages.
pdfWriteBlockedLogSignature(&$pdf, $outputlangs, $page_height, $object, &$w, &$posx, &$posy)
Add some information from the blockedlog module.
isALNEQualifiedVersion($ignoredev=0, $ignoremodule=0)
Return if the version is a candidate version to get the LNE certification and if the prerequisites ar...
isRegistrationDataSaved()
Return if the KYC mandatory parameters are set Must be the same fields than the one defined as mandat...
userIsTaxAuditor()
Call remote API service to push the last counter and signature.
pdfCertifMentionblockedLog(&$pdf, $outputlangs, $seller, $default_font_size, &$posy, $pdftemplate)
Add legal mention.
isBlockedLogUsed($ignoresystem=0)
Return if the blocked log was already used to block some events.
blockedlogadmin_prepare_head($withtabsetup)
Define head array for tabs of blockedlog tools setup pages.
isRegistrationDataSavedAndPushed()
Return if the KYC mandatory parameters are set AND pushed/registered centralized server.
getHashUniqueIdOfRegistration($algo='sha256')
Return a hash unique identifier of the registration (used to identify the registration of instance wi...
isALNERunningVersion($blockedlogtestalreadydone=0, $blockedlogmodulealreadydone=0)
Return if the application is executed with the LNE requirements on.
callApiToGetObfuscationKey($idprof1, $registrationnumber, $force=false)
Call remote API service to get the obfuscation key.
Class to manage Blocked Log.
Class to manage third parties objects (customers, suppliers, prospects...)
dol_dir_list($utf8_path, $types="all", $recursive=0, $filter="", $excludefilter=null, $sortcriteria="name", $sortorder=SORT_ASC, $mode=0, $nohook=0, $relativename="", $donotfollowsymlinks=0, $nbsecondsold=0)
Scan a directory and return a list of files/directories.
dol_now($mode='gmt')
Return date for now.
dolChmod($filepath, $newmask='')
Change mod of a file.
getMultidirOutput($object, $module='', $forobject=0, $mode='output')
Return the full path of the directory where a module (or an object of a module) stores its files.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0, $nodefault=0)
Return value of a param into GET or POST supervariable.
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs=null, $encodetooutput=false, $decorate=0)
Output date in a string format according to outputlangs (or langs if not defined).
dol_trunc($string, $size=40, $trunc='right', $stringencoding='UTF-8', $nodot=0, $display=0)
Truncate a string to a particular length adding '...' if string larger than length.
complete_head_from_modules($conf, $langs, $object, &$head, &$h, $type, $mode='add', $filterorigmodule='')
Complete or removed entries into a head array (used to build tabs).
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
dol_sanitizeKeyCode($str)
Clean a string to use it as a key or code.
isModEnabled($module)
Is Dolibarr module enabled.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
getURLContent($url, $postorget='GET', $param='', $followlocation=1, $addheaders=array(), $allowedschemes=array('http', 'https'), $localurl=0, $ssl_verifypeer=-1, $timeoutconnect=0, $timeoutresponse=0, $otherCurlOptions=array(), $morelogsuffix='')
Function to get a content from an URL (use proxy if proxy defined).
dol_print_error($db=null, $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
print $langs trans("Show") . '< td style="' . $timeColor . '" align="center"> s</td > badge status0 badge status4 badge status3 Error badge status8< td align="center">< span class="badge ' . $badge . '"></span ></td >< td align="center">< a href="#" class="button button-small" onclick="openLogModal(this)" data-req="' . dol_escape_htmltag($reqSafe) . '" data-res="' . dol_escape_htmltag($resSafe) . '" data-err="' . dol_escape_htmltag($errSafe) . '">< span class="fa fa-search-plus"></span ></a ></td ></tr >< tr >< td colspan="' . $colspan . '" class="opacitymedium"></td ></tr ></table ></div ></form > logModal none logModal none s a JSON string
dol_hash($chain, $type='0', $nosalt=0, $mode=0)
Returns a hash (non reversible encryption) of a string.
dolEncrypt($chain, $key='', $ciphering='', $forceseed='', $obfuscationmode='dolcrypt')
Encode a string with a symmetric encryption.