48 public $errors = array();
54 public $signature =
'';
60 public $signature_line =
'';
62 public $amounts =
null;
80 public $fk_object = 0;
86 public $certified =
false;
97 public $date_creation;
102 public $date_modification;
104 public $date_object = 0;
106 public $ref_object =
'';
108 public $object_data =
null;
109 public $object_version =
'';
111 public $user_fullname =
'';
117 public $trackedevents = array();
141 $this->trackedevents = array();
145 $this->trackedevents[
'BILL_VALIDATE'] =
'logBILL_VALIDATE';
146 $this->trackedevents[
'BILL_DELETE'] =
'logBILL_DELETE';
147 $this->trackedevents[
'BILL_SENTBYMAIL'] =
'logBILL_SENTBYMAIL';
148 $this->trackedevents[
'DOC_DOWNLOAD'] =
'BlockedLogBillDownload';
149 $this->trackedevents[
'DOC_PREVIEW'] =
'BlockedLogBillPreview';
150 $this->trackedevents[
'PAYMENT_CUSTOMER_CREATE'] =
'logPAYMENT_CUSTOMER_CREATE';
151 $this->trackedevents[
'PAYMENT_CUSTOMER_DELETE'] =
'logPAYMENT_CUSTOMER_DELETE';
169 $this->trackedevents[
'DON_VALIDATE'] =
'logDON_VALIDATE';
170 $this->trackedevents[
'DON_DELETE'] =
'logDON_DELETE';
172 $this->trackedevents[
'DONATION_PAYMENT_CREATE'] =
'logDONATION_PAYMENT_CREATE';
173 $this->trackedevents[
'DONATION_PAYMENT_DELETE'] =
'logDONATION_PAYMENT_DELETE';
187 $this->trackedevents[
'MEMBER_SUBSCRIPTION_CREATE'] =
'logMEMBER_SUBSCRIPTION_CREATE';
188 $this->trackedevents[
'MEMBER_SUBSCRIPTION_MODIFY'] =
'logMEMBER_SUBSCRIPTION_MODIFY';
189 $this->trackedevents[
'MEMBER_SUBSCRIPTION_DELETE'] =
'logMEMBER_SUBSCRIPTION_DELETE';
194 $this->trackedevents[
'PAYMENT_VARIOUS_CREATE'] =
'logPAYMENT_VARIOUS_CREATE';
195 $this->trackedevents[
'PAYMENT_VARIOUS_MODIFY'] =
'logPAYMENT_VARIOUS_MODIFY';
196 $this->trackedevents[
'PAYMENT_VARIOUS_DELETE'] =
'logPAYMENT_VARIOUS_DELETE';
201 $moduleposenabled = (!empty($conf->cashdesk->enabled) || !empty($conf->takepos->enabled) || !empty($conf->global->BANK_ENABLE_POS_CASHCONTROL));
202 if ($moduleposenabled) {
203 $this->trackedevents[
'CASHCONTROL_VALIDATE'] =
'logCASHCONTROL_VALIDATE';
208 if (!empty($conf->global->BLOCKEDLOG_ADD_ACTIONS_SUPPORTED)) {
209 $tmparrayofmoresupportedevents = explode(
',', $conf->global->BLOCKEDLOG_ADD_ACTIONS_SUPPORTED);
210 foreach ($tmparrayofmoresupportedevents as $val) {
211 $this->trackedevents[$val] =
'log'.$val;
227 if ($this->element ===
'facture') {
228 require_once DOL_DOCUMENT_ROOT.
'/compta/facture/class/facture.class.php';
231 if ($object->fetch($this->fk_object) > 0) {
232 return $object->getNomUrl(1);
237 if ($this->element ===
'invoice_supplier') {
238 require_once DOL_DOCUMENT_ROOT.
'/fourn/class/fournisseur.facture.class.php';
241 if ($object->fetch($this->fk_object) > 0) {
242 return $object->getNomUrl(1);
246 } elseif ($this->element ===
'payment') {
247 require_once DOL_DOCUMENT_ROOT.
'/compta/paiement/class/paiement.class.php';
250 if ($object->fetch($this->fk_object) > 0) {
251 return $object->getNomUrl(1);
255 } elseif ($this->element ===
'payment_supplier') {
256 require_once DOL_DOCUMENT_ROOT.
'/fourn/class/paiementfourn.class.php';
259 if ($object->fetch($this->fk_object) > 0) {
260 return $object->getNomUrl(1);
264 } elseif ($this->element ===
'payment_donation') {
265 require_once DOL_DOCUMENT_ROOT.
'/don/class/paymentdonation.class.php';
268 if ($object->fetch($this->fk_object) > 0) {
269 return $object->getNomUrl(1);
273 } elseif ($this->element ===
'payment_various') {
274 require_once DOL_DOCUMENT_ROOT.
'/compta/bank/class/paymentvarious.class.php';
277 if ($object->fetch($this->fk_object) > 0) {
278 return $object->getNomUrl(1);
282 } elseif ($this->element ===
'don' || $this->element ===
'donation') {
283 require_once DOL_DOCUMENT_ROOT.
'/don/class/don.class.php';
285 $object =
new Don($this->
db);
286 if ($object->fetch($this->fk_object) > 0) {
287 return $object->getNomUrl(1);
291 } elseif ($this->element ===
'subscription') {
292 require_once DOL_DOCUMENT_ROOT.
'/adherents/class/subscription.class.php';
295 if ($object->fetch($this->fk_object) > 0) {
296 return $object->getNomUrl(1);
300 } elseif ($this->element ===
'cashcontrol') {
301 require_once DOL_DOCUMENT_ROOT.
'/compta/cashcontrol/class/cashcontrol.class.php';
304 if ($object->fetch($this->fk_object) > 0) {
305 return $object->getNomUrl(1);
309 } elseif ($this->element ===
'stockmouvement') {
310 require_once DOL_DOCUMENT_ROOT.
'/product/stock/class/mouvementstock.class.php';
313 if ($object->fetch($this->fk_object) > 0) {
314 return $object->getNomUrl(1);
318 } elseif ($this->action ==
'MODULE_SET') {
319 return '<i class="opacitymedium">'.$langs->trans(
"BlockedLogEnabled").
'</i>';
320 } elseif ($this->action ==
'MODULE_RESET') {
321 if ($this->signature ==
'0000000000') {
322 return '<i class="opacitymedium">'.$langs->trans(
"BlockedLogDisabled").
'</i>';
324 return '<i class="opacitymedium">'.$langs->trans(
"BlockedLogDisabledBis").
'</i>';
328 return '<i class="opacitymedium">'.$langs->trans(
'ImpossibleToReloadObject', $this->element, $this->fk_object).
'</i>';
337 global $langs, $cachedUser;
339 if (empty($cachedUser)) {
340 $cachedUser = array();
343 if (empty($cachedUser[$this->fk_user])) {
345 if ($u->fetch($this->fk_user) > 0) {
346 $cachedUser[$this->fk_user] = $u;
350 if (!empty($cachedUser[$this->fk_user])) {
351 return $cachedUser[$this->fk_user]->getNomUrl(1);
354 return $langs->trans(
'ImpossibleToRetrieveUser', $this->fk_user);
368 global $langs, $user, $mysoc;
370 if (is_object($fuser)) {
377 $this->action = $action;
379 $this->amounts = $amounts;
381 if ($object->element ==
'payment' || $object->element ==
'payment_supplier') {
382 $this->date_object = empty($object->datepaye) ? $object->date : $object->datepaye;
383 } elseif ($object->element ==
'payment_salary') {
384 $this->date_object = $object->datev;
385 } elseif ($object->element ==
'payment_donation' || $object->element ==
'payment_various') {
386 $this->date_object = empty($object->datepaid) ? $object->datep : $object->datepaid;
387 } elseif ($object->element ==
'subscription') {
388 $this->date_object = $object->dateh;
389 } elseif ($object->element ==
'cashcontrol') {
390 $this->date_object = $object->date_creation;
391 } elseif (property_exists($object,
'date')) {
393 $this->date_object = $object->date;
394 } elseif (property_exists($object,
'datem')) {
396 $this->date_object = $object->datem;
400 $this->ref_object = ((!empty($object->newref)) ? $object->newref : $object->ref);
402 $this->element = $object->element;
404 $this->fk_object = $object->id;
408 $this->object_data =
new stdClass();
410 $arrayoffieldstoexclude = array(
411 'table_element',
'fields',
'ref_previous',
'ref_next',
'origin',
'origin_id',
'oldcopy',
'picto',
'error',
'errors',
'model_pdf',
'modelpdf',
'last_main_doc',
'civility_id',
'contact',
'contact_id',
412 'table_element_line',
'ismultientitymanaged',
'isextrafieldmanaged',
421 'fk_delivery_address',
423 'restrictiononfksoc',
427 if ($this->element ==
'cashcontrol') {
428 $arrayoffieldstoexclude = array_merge($arrayoffieldstoexclude, array(
429 'name',
'lastname',
'firstname',
'region',
'region_id',
'region_code',
'state',
'state_id',
'state_code',
'country',
'country_id',
'country_code',
430 'total_ht',
'total_tva',
'total_ttc',
'total_localtax1',
'total_localtax2',
431 'barcode_type',
'barcode_type_code',
'barcode_type_label',
'barcode_type_coder',
'mode_reglement_id',
'cond_reglement_id',
'mode_reglement',
'cond_reglement',
'shipping_method_id',
432 'fk_incoterms',
'label_incoterms',
'location_incoterms',
'lines'));
436 if (empty($object->thirdparty) && method_exists($object,
'fetch_thirdparty')) {
437 $object->fetch_thirdparty();
439 if (!empty($object->thirdparty)) {
440 $this->object_data->thirdparty =
new stdClass();
442 foreach ($object->thirdparty as $key => $value) {
443 if (in_array($key, $arrayoffieldstoexclude)) {
446 if (!in_array($key, array(
447 'name',
'name_alias',
'ref_ext',
'address',
'zip',
'town',
'state_code',
'country_code',
'idprof1',
'idprof2',
'idprof3',
'idprof4',
'idprof5',
'idprof6',
'phone',
'fax',
'email',
'barcode',
448 'tva_intra',
'localtax1_assuj',
'localtax1_value',
'localtax2_assuj',
'localtax2_value',
'managers',
'capital',
'typent_code',
'forme_juridique_code',
'code_client',
'code_fournisseur'
452 if (!is_object($value) && !is_null($value) && $value !==
'') {
453 $this->object_data->thirdparty->$key = $value;
459 if (!empty($mysoc)) {
460 $this->object_data->mycompany =
new stdClass();
462 foreach ($mysoc as $key => $value) {
463 if (in_array($key, $arrayoffieldstoexclude)) {
466 if (!in_array($key, array(
467 'name',
'name_alias',
'ref_ext',
'address',
'zip',
'town',
'state_code',
'country_code',
'idprof1',
'idprof2',
'idprof3',
'idprof4',
'idprof5',
'idprof6',
'phone',
'fax',
'email',
'barcode',
468 'tva_intra',
'localtax1_assuj',
'localtax1_value',
'localtax2_assuj',
'localtax2_value',
'managers',
'capital',
'typent_code',
'forme_juridique_code',
'code_client',
'code_fournisseur'
472 if (!is_object($value) && !is_null($value) && $value !==
'') {
473 $this->object_data->mycompany->$key = $value;
480 $this->fk_user = $user->id;
481 $this->user_fullname = $user->getFullName($langs);
485 if ($this->element ==
'facture') {
486 foreach ($object as $key => $value) {
487 if (in_array($key, $arrayoffieldstoexclude)) {
490 if (!in_array($key, array(
491 'ref',
'ref_client',
'ref_supplier',
'date',
'datef',
'datev',
'type',
'total_ht',
'total_tva',
'total_ttc',
'localtax1',
'localtax2',
'revenuestamp',
'datepointoftax',
'note_public',
'lines'
495 if ($key ==
'lines') {
497 foreach ($value as $tmpline) {
499 foreach ($tmpline as $keyline => $valueline) {
500 if (!in_array($keyline, array(
501 'ref',
'multicurrency_code',
'multicurrency_total_ht',
'multicurrency_total_tva',
'multicurrency_total_ttc',
'qty',
'product_type',
'vat_src_code',
'tva_tx',
'info_bits',
'localtax1_tx',
'localtax2_tx',
'total_ht',
'total_tva',
'total_ttc',
'total_localtax1',
'total_localtax2'
506 if (empty($this->object_data->invoiceline[$lineid]) || !is_object($this->object_data->invoiceline[$lineid])) {
507 $this->object_data->invoiceline[$lineid] =
new stdClass();
510 if (!is_object($valueline) && !is_null($valueline) && $valueline !==
'') {
511 $this->object_data->invoiceline[$lineid]->$keyline = $valueline;
515 } elseif (!is_object($value) && !is_null($value) && $value !==
'') {
516 $this->object_data->$key = $value;
520 if (!empty($object->newref)) {
521 $this->object_data->ref = $object->newref;
523 } elseif ($this->element ==
'invoice_supplier') {
524 foreach ($object as $key => $value) {
525 if (in_array($key, $arrayoffieldstoexclude)) {
528 if (!in_array($key, array(
529 'ref',
'ref_client',
'ref_supplier',
'date',
'datef',
'type',
'total_ht',
'total_tva',
'total_ttc',
'localtax1',
'localtax2',
'revenuestamp',
'datepointoftax',
'note_public'
533 if (!is_object($value) && !is_null($value) && $value !==
'') {
534 $this->object_data->$key = $value;
538 if (!empty($object->newref)) {
539 $this->object_data->ref = $object->newref;
541 } elseif ($this->element ==
'payment' || $this->element ==
'payment_supplier' || $this->element ==
'payment_donation' || $this->element ==
'payment_various') {
542 $datepayment = $object->datepaye ? $object->datepaye : ($object->datepaid ? $object->datepaid : $object->datep);
543 $paymenttypeid = $object->paiementid ? $object->paiementid : ($object->paymenttype ? $object->paymenttype : $object->type_payment);
545 $this->object_data->ref = $object->ref;
546 $this->object_data->date = $datepayment;
547 $this->object_data->type_code =
dol_getIdFromCode($this->
db, $paymenttypeid,
'c_paiement',
'id',
'code');
549 if (!empty($object->num_payment)) {
550 $this->object_data->payment_num = $object->num_payment;
552 if (!empty($object->note_private)) {
553 $this->object_data->note_private = $object->note_private;
561 if (is_array($object->amounts) && !empty($object->amounts)) {
562 $paymentpartnumber = 0;
563 foreach ($object->amounts as $objid => $amount) {
564 if (empty($amount)) {
568 $totalamount += $amount;
571 if ($this->element ==
'payment_supplier') {
572 include_once DOL_DOCUMENT_ROOT.
'/fourn/class/fournisseur.facture.class.php';
574 } elseif ($this->element ==
'payment') {
575 include_once DOL_DOCUMENT_ROOT.
'/compta/facture/class/facture.class.php';
577 } elseif ($this->element ==
'payment_donation') {
578 include_once DOL_DOCUMENT_ROOT.
'/don/class/don.class.php';
579 $tmpobject =
new Don($this->
db);
580 } elseif ($this->element ==
'payment_various') {
581 include_once DOL_DOCUMENT_ROOT.
'/compta/bank/class/paymentvarious.class.php';
585 if (!is_object($tmpobject)) {
589 $result = $tmpobject->fetch($objid);
592 $this->error = $tmpobject->error;
593 $this->errors = $tmpobject->errors;
594 dol_syslog(
"Failed to fetch object with id ".$objid, LOG_ERR);
598 $paymentpart =
new stdClass();
599 $paymentpart->amount = $amount;
601 if (!in_array($this->element, array(
'payment_donation',
'payment_various'))) {
602 $result = $tmpobject->fetch_thirdparty();
604 $this->error =
'Failed to fetch thirdparty for object with id '.$tmpobject->id;
605 $this->errors[] = $this->error;
606 dol_syslog(
"Failed to fetch thirdparty for object with id ".$tmpobject->id, LOG_ERR);
608 } elseif ($result < 0) {
609 $this->error = $tmpobject->error;
610 $this->errors = $tmpobject->errors;
614 $paymentpart->thirdparty =
new stdClass();
615 foreach ($tmpobject->thirdparty as $key => $value) {
616 if (in_array($key, $arrayoffieldstoexclude)) {
619 if (!in_array($key, array(
620 'name',
'name_alias',
'ref_ext',
'address',
'zip',
'town',
'state_code',
'country_code',
'idprof1',
'idprof2',
'idprof3',
'idprof4',
'idprof5',
'idprof6',
'phone',
'fax',
'email',
'barcode',
621 'tva_intra',
'localtax1_assuj',
'localtax1_value',
'localtax2_assuj',
'localtax2_value',
'managers',
'capital',
'typent_code',
'forme_juridique_code',
'code_client',
'code_fournisseur'
625 if (!is_object($value) && !is_null($value) && $value !==
'') {
626 $paymentpart->thirdparty->$key = $value;
632 if ($this->element ==
'payment_donation') {
633 $paymentpart->donation =
new stdClass();
635 $paymentpart->invoice =
new stdClass();
638 if ($this->element !=
'payment_various') {
639 foreach ($tmpobject as $key => $value) {
640 if (in_array($key, $arrayoffieldstoexclude)) {
643 if (!in_array($key, array(
644 'ref',
'ref_client',
'ref_supplier',
'date',
'datef',
'type',
'total_ht',
'total_tva',
'total_ttc',
'localtax1',
'localtax2',
'revenuestamp',
'datepointoftax',
'note_public'
648 if (!is_object($value) && !is_null($value) && $value !==
'') {
649 if ($this->element ==
'payment_donation') {
650 $paymentpart->donation->$key = $value;
651 } elseif ($this->element ==
'payment_various') {
652 $paymentpart->various->$key = $value;
654 $paymentpart->invoice->$key = $value;
659 $paymentpartnumber++;
660 $this->object_data->payment_part[$paymentpartnumber] = $paymentpart;
663 } elseif (!empty($object->amount)) {
664 $totalamount = $object->amount;
667 $this->object_data->amount = $totalamount;
669 if (!empty($object->newref)) {
670 $this->object_data->ref = $object->newref;
672 } elseif ($this->element ==
'payment_salary') {
673 $this->object_data->amounts = array($object->amount);
675 if (!empty($object->newref)) {
676 $this->object_data->ref = $object->newref;
678 } elseif ($this->element ==
'subscription') {
679 foreach ($object as $key => $value) {
680 if (in_array($key, $arrayoffieldstoexclude)) {
683 if (!in_array($key, array(
684 'id',
'datec',
'dateh',
'datef',
'fk_adherent',
'amount',
'import_key',
'statut',
'note'
688 if (!is_object($value) && !is_null($value) && $value !==
'') {
689 $this->object_data->$key = $value;
693 if (!empty($object->newref)) {
694 $this->object_data->ref = $object->newref;
696 } elseif ($this->element ==
'stockmouvement') {
697 foreach ($object as $key => $value) {
698 if (in_array($key, $arrayoffieldstoexclude)) {
701 if (!is_object($value) && !is_null($value) && $value !==
'') {
702 $this->object_data->$key = $value;
707 foreach ($object as $key => $value) {
708 if (in_array($key, $arrayoffieldstoexclude)) {
711 if (!is_object($value) && !is_null($value) && $value !==
'') {
712 $this->object_data->$key = $value;
716 if (!empty($object->newref)) {
717 $this->object_data->ref = $object->newref;
723 $this->object_data = json_decode(json_encode($this->object_data, JSON_FORCE_OBJECT),
false);
739 $this->error =
'BadParameter';
743 $sql =
"SELECT b.rowid, b.date_creation, b.signature, b.signature_line, b.amounts, b.action, b.element, b.fk_object, b.entity,";
744 $sql .=
" b.certified, b.tms, b.fk_user, b.user_fullname, b.date_object, b.ref_object, b.object_data, b.object_version";
745 $sql .=
" FROM ".MAIN_DB_PREFIX.
"blockedlog as b";
747 $sql .=
" WHERE b.rowid = ".((int) $id);
752 $obj = $this->
db->fetch_object(
$resql);
754 $this->
id = $obj->rowid;
755 $this->entity = $obj->entity;
756 $this->
ref = $obj->rowid;
758 $this->date_creation = $this->
db->jdate($obj->date_creation);
759 $this->tms = $this->
db->jdate($obj->tms);
761 $this->amounts = (double) $obj->amounts;
762 $this->action = $obj->action;
763 $this->element = $obj->element;
765 $this->fk_object = $obj->fk_object;
766 $this->date_object = $this->db->jdate($obj->date_object);
767 $this->ref_object = $obj->ref_object;
769 $this->fk_user = $obj->fk_user;
770 $this->user_fullname = $obj->user_fullname;
773 $this->object_version = $obj->object_version;
775 $this->signature = $obj->signature;
776 $this->signature_line = $obj->signature_line;
777 $this->certified = ($obj->certified == 1);
781 $langs->load(
"blockedlog");
782 $this->error = $langs->trans(
"RecordNotFound");
786 $this->error = $this->
db->error();
802 $aaa = json_encode($data);
840 $res = $this->
db->query(
"UPDATE ".MAIN_DB_PREFIX.
"blockedlog SET certified=1 WHERE rowid=".((
int) $this->id));
855 public function create($user, $forcesignature =
'')
857 global $conf, $langs, $hookmanager;
859 $langs->load(
'blockedlog');
864 $this->amounts = (double) $this->amounts;
866 dol_syslog(get_class($this).
'::create action='.$this->action.
' fk_user='.$this->fk_user.
' user_fullname='.$this->user_fullname, LOG_DEBUG);
869 if (!isset($this->amounts)) {
870 $this->error = $langs->trans(
"BlockLogNeedAmountsValue");
875 if (empty($this->element)) {
876 $this->error = $langs->trans(
"BlockLogNeedElement");
881 if (empty($this->action)) {
882 $this->error = $langs->trans(
"BadParameterWhenCallingCreateOfBlockedLog");
886 if (empty($this->fk_user)) {
887 $this->user_fullname =
'(Anonymous)';
890 $this->date_creation =
dol_now();
892 $this->object_version = ((
float) DOL_VERSION);
901 include_once DOL_DOCUMENT_ROOT.
'/core/lib/security.lib.php';
903 $this->signature_line =
dol_hash($keyforsignature,
'5');
904 $this->signature =
dol_hash($previoushash.$keyforsignature,
'5');
905 if ($forcesignature) {
906 $this->signature = $forcesignature;
910 $sql =
"INSERT INTO ".MAIN_DB_PREFIX.
"blockedlog (";
911 $sql .=
" date_creation,";
914 $sql .=
" signature,";
915 $sql .=
" signature_line,";
917 $sql .=
" fk_object,";
918 $sql .=
" date_object,";
919 $sql .=
" ref_object,";
920 $sql .=
" object_data,";
921 $sql .=
" object_version,";
922 $sql .=
" certified,";
924 $sql .=
" user_fullname,";
926 $sql .=
") VALUES (";
927 $sql .=
"'".$this->db->idate($this->date_creation).
"',";
928 $sql .=
"'".$this->db->escape($this->action).
"',";
929 $sql .= $this->amounts.
",";
930 $sql .=
"'".$this->db->escape($this->signature).
"',";
931 $sql .=
"'".$this->db->escape($this->signature_line).
"',";
932 $sql .=
"'".$this->db->escape($this->element).
"',";
933 $sql .= $this->fk_object.
",";
934 $sql .=
"'".$this->db->idate($this->date_object).
"',";
935 $sql .=
"'".$this->db->escape($this->ref_object).
"',";
937 $sql .=
"'".$this->db->escape($this->object_version).
"',";
939 $sql .= $this->fk_user.
",";
940 $sql .=
"'".$this->db->escape($this->user_fullname).
"',";
941 $sql .= ($this->entity ? $this->entity : $conf->entity);
952 $res = $this->
db->query($sql);
954 $id = $this->
db->last_insert_id(MAIN_DB_PREFIX.
"blockedlog");
963 $this->
db->rollback();
967 $this->error = $this->
db->error();
968 $this->
db->rollback();
984 if (empty($previoushash)) {
991 $signature =
dol_hash($previoushash.$keyforsignature,
'sha256');
994 $res = ($signature === $this->signature);
997 $this->error =
'Signature KO';
1001 if ($returnarray == 1) {
1002 unset($keyforsignature);
1003 return array(
'checkresult' => $res,
'calculatedsignature' => $signature,
'previoushash' => $previoushash);
1005 return array(
'checkresult' => $res,
'calculatedsignature' => $signature,
'previoushash' => $previoushash,
'keyforsignature'=>$keyforsignature);
1008 unset($keyforsignature);
1023 if (((
int) $this->object_version) >= 18) {
1024 return $this->date_creation.
'|'.$this->action.
'|'.$this->amounts.
'|'.$this->ref_object.
'|'.$this->date_object.
'|'.$this->user_fullname.
'|'.json_encode($this->object_data, JSON_FORCE_OBJECT);
1026 return $this->date_creation.
'|'.$this->action.
'|'.$this->amounts.
'|'.$this->ref_object.
'|'.$this->date_object.
'|'.$this->user_fullname.
'|'.print_r($this->object_data,
true);
1042 $previoussignature =
'';
1044 $sql =
"SELECT rowid, signature FROM ".MAIN_DB_PREFIX.
"blockedlog";
1045 $sql .=
" WHERE entity = ".((int) $conf->entity);
1047 $sql .=
" AND rowid < ".(int) $beforeid;
1049 $sql .=
" ORDER BY rowid DESC LIMIT 1";
1050 $sql .= ($withlock ?
" FOR UPDATE " :
"");
1054 $obj = $this->
db->fetch_object(
$resql);
1056 $previoussignature = $obj->signature;
1063 if (empty($previoussignature)) {
1068 return $previoussignature;
1087 public function getLog($element, $fk_object, $limit = 0, $sortfield =
'', $sortorder =
'', $search_fk_user = -1, $search_start = -1, $search_end = -1, $search_ref =
'', $search_amount =
'', $search_code =
'')
1095 if ($element ==
'all') {
1096 $sql =
"SELECT rowid FROM ".MAIN_DB_PREFIX.
"blockedlog
1097 WHERE entity=".$conf->entity;
1098 } elseif ($element ==
'not_certified') {
1099 $sql =
"SELECT rowid FROM ".MAIN_DB_PREFIX.
"blockedlog
1100 WHERE entity=".$conf->entity.
" AND certified = 0";
1101 } elseif ($element ==
'just_certified') {
1102 $sql =
"SELECT rowid FROM ".MAIN_DB_PREFIX.
"blockedlog
1103 WHERE entity=".$conf->entity.
" AND certified = 1";
1105 $sql =
"SELECT rowid FROM ".MAIN_DB_PREFIX.
"blockedlog
1106 WHERE entity=".$conf->entity.
" AND element = '".$this->
db->escape($element).
"'";
1112 if ($search_fk_user > 0) {
1115 if ($search_start > 0) {
1116 $sql .=
" AND date_creation >= '".$this->db->idate($search_start).
"'";
1118 if ($search_end > 0) {
1119 $sql .=
" AND date_creation <= '".$this->db->idate($search_end).
"'";
1121 if ($search_ref !=
'') {
1124 if ($search_amount !=
'') {
1127 if ($search_code !=
'' && $search_code !=
'-1') {
1131 $sql .= $this->
db->order($sortfield, $sortorder);
1132 $sql .= $this->
db->plimit($limit + 1);
1134 $res = $this->
db->query($sql);
1139 while ($obj = $this->
db->fetch_object($res)) {
1149 $b->fetch($obj->rowid);
1171 global $db, $conf, $mysoc;
1173 if (empty($conf->global->BLOCKEDLOG_ENTITY_FINGERPRINT)) {
1174 require_once DOL_DOCUMENT_ROOT.
'/core/lib/admin.lib.php';
1175 require_once DOL_DOCUMENT_ROOT.
'/core/lib/security.lib.php';
1176 require_once DOL_DOCUMENT_ROOT.
'/core/lib/security2.lib.php';
1180 dolibarr_set_const($db,
'BLOCKEDLOG_ENTITY_FINGERPRINT', $fingerprint,
'chaine', 0,
'Numeric Unique Fingerprint', $conf->entity);
1182 $conf->global->BLOCKEDLOG_ENTITY_FINGERPRINT = $fingerprint;
1185 return $conf->global->BLOCKEDLOG_ENTITY_FINGERPRINT;
1201 $sql =
"SELECT rowid FROM ".MAIN_DB_PREFIX.
"blockedlog";
1202 $sql .=
" WHERE entity = ".$conf->entity;
1203 if ($ignoresystem) {
1204 $sql .=
" AND action not in ('MODULE_SET','MODULE_RESET')";
1206 $sql .= $this->
db->plimit(1);
1208 $res = $this->
db->query($sql);
1209 if ($res !==
false) {
1210 $obj = $this->
db->fetch_object($res);
1218 dol_syslog(
"Module Blockedlog alreadyUsed with ignoresystem=".$ignoresystem.
" is ".$result);
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).
Class to manage Blocked Log.
getSignature()
Return the signature (hash) of the "genesis-block" (Block 0).
getObjectLink()
Try to retrieve source object (it it still exists).
alreadyUsed($ignoresystem=0)
Check if module was already used or not for at least one recording.
buildKeyForSignature()
Return a string for signature.
create($user, $forcesignature='')
Create blocked log in database.
dolEncodeBlockedData($data, $mode=0)
Encode data.
loadTrackedEvents()
Load list of tracked events into $this->trackedevents.
getLog($element, $fk_object, $limit=0, $sortfield='', $sortorder='', $search_fk_user=-1, $search_start=-1, $search_end=-1, $search_ref='', $search_amount='', $search_code='')
Return array of log objects (with criterias)
__construct(DoliDB $db)
Constructor.
setObjectData(&$object, $action, $amounts, $fuser=null)
Populate properties of log from object data.
getPreviousHash($withlock=0, $beforeid=0)
Get previous signature/hash in chain.
checkSignature($previoushash='', $returnarray=0)
Check if current signature still correct compared to the value in chain.
dolDecodeBlockedData($data, $mode=0)
Decode data.
fetch($id)
Get object from database.
setCertified()
Set block certified by authority.
Class to manage cash fence.
Class to manage Dolibarr database access.
Class to manage donations.
Class to manage suppliers invoices.
Class to manage invoices.
Class to manage stock movements.
Class to manage payments for supplier invoices.
Class to manage payments of customer invoices.
Class to manage payments of donations.
Class to manage various payments.
Class to manage subscriptions of foundation members.
Class to manage Dolibarr users.
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.
dol_print_error($db='', $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
natural_search($fields, $value, $mode=0, $nofirstand=0)
Generate natural SQL search string for a criteria (this criteria can be tested on one or several fiel...
dol_now($mode='auto')
Return date for now.
dol_getIdFromCode($db, $key, $tablename, $fieldkey='code', $fieldid='id', $entityfilter=0, $filters='')
Return an id or code from a code or id.
jsonOrUnserialize($stringtodecode)
Decode an encode string.
isModEnabled($module)
Is Dolibarr module enabled.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
div float
Buy price without taxes.
getRandomPassword($generic=false, $replaceambiguouschars=null, $length=32)
Return a generated password using default module.
dol_hash($chain, $type='0')
Returns a hash (non reversible encryption) of a string.
$conf db
API class for accounts.