47 public $errors = array();
53 public $signature =
'';
59 public $signature_line =
'';
61 public $amounts = null;
79 public $fk_object = 0;
85 public $certified =
false;
96 public $date_creation;
101 public $date_modification;
103 public $date_object = 0;
105 public $ref_object =
'';
107 public $object_data = null;
108 public $object_version =
'';
110 public $user_fullname =
'';
116 public $trackedevents = array();
131 $this->trackedevents = array();
133 if ($conf->facture->enabled) $this->trackedevents[
'BILL_VALIDATE'] =
'logBILL_VALIDATE';
134 if ($conf->facture->enabled) $this->trackedevents[
'BILL_DELETE'] =
'logBILL_DELETE';
135 if ($conf->facture->enabled) $this->trackedevents[
'BILL_SENTBYMAIL'] =
'logBILL_SENTBYMAIL';
136 if ($conf->facture->enabled) $this->trackedevents[
'DOC_DOWNLOAD'] =
'BlockedLogBillDownload';
137 if ($conf->facture->enabled) $this->trackedevents[
'DOC_PREVIEW'] =
'BlockedLogBillPreview';
139 if ($conf->facture->enabled) $this->trackedevents[
'PAYMENT_CUSTOMER_CREATE'] =
'logPAYMENT_CUSTOMER_CREATE';
140 if ($conf->facture->enabled) $this->trackedevents[
'PAYMENT_CUSTOMER_DELETE'] =
'logPAYMENT_CUSTOMER_DELETE';
153 if ($conf->don->enabled) $this->trackedevents[
'DON_VALIDATE'] =
'logDON_VALIDATE';
154 if ($conf->don->enabled) $this->trackedevents[
'DON_DELETE'] =
'logDON_DELETE';
157 if ($conf->don->enabled) $this->trackedevents[
'DONATION_PAYMENT_CREATE'] =
'logDONATION_PAYMENT_CREATE';
158 if ($conf->don->enabled) $this->trackedevents[
'DONATION_PAYMENT_DELETE'] =
'logDONATION_PAYMENT_DELETE';
166 if ($conf->adherent->enabled) $this->trackedevents[
'MEMBER_SUBSCRIPTION_CREATE'] =
'logMEMBER_SUBSCRIPTION_CREATE';
167 if ($conf->adherent->enabled) $this->trackedevents[
'MEMBER_SUBSCRIPTION_MODIFY'] =
'logMEMBER_SUBSCRIPTION_MODIFY';
168 if ($conf->adherent->enabled) $this->trackedevents[
'MEMBER_SUBSCRIPTION_DELETE'] =
'logMEMBER_SUBSCRIPTION_DELETE';
171 if ($conf->banque->enabled) $this->trackedevents[
'PAYMENT_VARIOUS_CREATE'] =
'logPAYMENT_VARIOUS_CREATE';
172 if ($conf->banque->enabled) $this->trackedevents[
'PAYMENT_VARIOUS_MODIFY'] =
'logPAYMENT_VARIOUS_MODIFY';
173 if ($conf->banque->enabled) $this->trackedevents[
'PAYMENT_VARIOUS_DELETE'] =
'logPAYMENT_VARIOUS_DELETE';
176 $moduleposenabled = (!empty($conf->cashdesk->enabled) || !empty($conf->takepos->enabled) || !empty($conf->global->BANK_ENABLE_POS_CASHCONTROL));
177 if ($moduleposenabled) $this->trackedevents[
'CASHCONTROL_VALIDATE'] =
'logCASHCONTROL_VALIDATE';
179 if (!empty($conf->global->BLOCKEDLOG_ADD_ACTIONS_SUPPORTED)) {
180 $tmparrayofmoresupportedevents = explode(
',', $conf->global->BLOCKEDLOG_ADD_ACTIONS_SUPPORTED);
181 foreach ($tmparrayofmoresupportedevents as $val) {
182 $this->trackedevents[$val] =
'log'.$val;
195 if ($this->element ===
'facture') {
196 require_once DOL_DOCUMENT_ROOT.
'/compta/facture/class/facture.class.php';
199 if ($object->fetch($this->fk_object) > 0) {
200 return $object->getNomUrl(1);
205 if ($this->element ===
'invoice_supplier') {
206 require_once DOL_DOCUMENT_ROOT.
'/fourn/class/fournisseur.facture.class.php';
209 if ($object->fetch($this->fk_object) > 0) {
210 return $object->getNomUrl(1);
214 } elseif ($this->element ===
'payment') {
215 require_once DOL_DOCUMENT_ROOT.
'/compta/paiement/class/paiement.class.php';
218 if ($object->fetch($this->fk_object) > 0) {
219 return $object->getNomUrl(1);
223 } elseif ($this->element ===
'payment_supplier') {
224 require_once DOL_DOCUMENT_ROOT.
'/fourn/class/paiementfourn.class.php';
227 if ($object->fetch($this->fk_object) > 0) {
228 return $object->getNomUrl(1);
232 } elseif ($this->element ===
'payment_donation') {
233 require_once DOL_DOCUMENT_ROOT.
'/don/class/paymentdonation.class.php';
236 if ($object->fetch($this->fk_object) > 0) {
237 return $object->getNomUrl(1);
241 } elseif ($this->element ===
'payment_various') {
242 require_once DOL_DOCUMENT_ROOT.
'/compta/bank/class/paymentvarious.class.php';
245 if ($object->fetch($this->fk_object) > 0) {
246 return $object->getNomUrl(1);
250 } elseif ($this->element ===
'don' || $this->element ===
'donation') {
251 require_once DOL_DOCUMENT_ROOT.
'/don/class/don.class.php';
253 $object =
new Don($this->
db);
254 if ($object->fetch($this->fk_object) > 0) {
255 return $object->getNomUrl(1);
259 } elseif ($this->element ===
'subscription') {
260 require_once DOL_DOCUMENT_ROOT.
'/adherents/class/subscription.class.php';
263 if ($object->fetch($this->fk_object) > 0) {
264 return $object->getNomUrl(1);
268 } elseif ($this->element ===
'cashcontrol') {
269 require_once DOL_DOCUMENT_ROOT.
'/compta/cashcontrol/class/cashcontrol.class.php';
272 if ($object->fetch($this->fk_object) > 0) {
273 return $object->getNomUrl(1);
277 } elseif ($this->action ==
'MODULE_SET')
279 return '<i class="opacitymedium">System to track events into unalterable logs were enabled</i>';
280 } elseif ($this->action ==
'MODULE_RESET')
282 if ($this->signature ==
'0000000000') {
283 return '<i class="opacitymedium">System to track events into unalterable logs were disabled after some recording were done. We saved a special Fingerprint to track the chain as broken.</i>';
285 return '<i class="opacitymedium">System to track events into unalterable logs were disabled. This is possible because no record were done yet.</i>';
289 return '<i class="opacitymedium">'.$langs->trans(
'ImpossibleToReloadObject', $this->element, $this->fk_object).
'</i>';
298 global $langs, $cachedUser;
300 if (empty($cachedUser))$cachedUser = array();
302 if (empty($cachedUser[$this->fk_user])) {
304 if ($u->fetch($this->fk_user) > 0) {
305 $cachedUser[$this->fk_user] = $u;
309 if (!empty($cachedUser[$this->fk_user])) {
310 return $cachedUser[$this->fk_user]->getNomUrl(1);
313 return $langs->trans(
'ImpossibleToRetrieveUser', $this->fk_user);
327 global $langs, $user, $mysoc;
329 if (is_object($fuser)) $user = $fuser;
334 $this->action = $action;
336 $this->amounts = $amounts;
338 if ($object->element ==
'payment' || $object->element ==
'payment_supplier')
340 $this->date_object = $object->datepaye;
341 } elseif ($object->element ==
'payment_salary')
343 $this->date_object = $object->datev;
344 } elseif ($object->element ==
'payment_donation' || $object->element ==
'payment_various')
346 $this->date_object = $object->datepaid ? $object->datepaid : $object->datep;
347 } elseif ($object->element ==
'subscription')
349 $this->date_object = $object->dateh;
350 } elseif ($object->element ==
'cashcontrol')
352 $this->date_object = $object->date_creation;
354 $this->date_object = $object->date;
357 $this->ref_object = ((!empty($object->newref)) ? $object->newref : $object->ref);
359 $this->element = $object->element;
361 $this->fk_object = $object->id;
365 $this->object_data =
new stdClass();
367 $arrayoffieldstoexclude = array(
368 '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',
369 'table_element_line',
'ismultientitymanaged',
'isextrafieldmanaged',
372 'fk_delivery_address',
377 if ($this->element ==
'cashcontrol') {
378 $arrayoffieldstoexclude = array_merge($arrayoffieldstoexclude, array(
379 'name',
'lastname',
'firstname',
'region',
'region_id',
'region_code',
'state',
'state_id',
'state_code',
'country',
'country_id',
'country_code',
380 'total_ht',
'total_tva',
'total_ttc',
'total_localtax1',
'total_localtax2',
381 'barcode_type',
'barcode_type_code',
'barcode_type_label',
'barcode_type_coder',
'mode_reglement_id',
'cond_reglement_id',
'mode_reglement',
'cond_reglement',
'shipping_method_id',
382 'fk_incoterms',
'label_incoterms',
'location_incoterms',
'lines')
387 if (empty($object->thirdparty) && method_exists($object,
'fetch_thirdparty')) $object->fetch_thirdparty();
388 if (!empty($object->thirdparty))
390 $this->object_data->thirdparty =
new stdClass();
392 foreach ($object->thirdparty as $key=>$value)
394 if (in_array($key, $arrayoffieldstoexclude))
continue;
395 if (!in_array($key, array(
396 'name',
'name_alias',
'ref_ext',
'address',
'zip',
'town',
'state_code',
'country_code',
'idprof1',
'idprof2',
'idprof3',
'idprof4',
'idprof5',
'idprof6',
'phone',
'fax',
'email',
'barcode',
397 'tva_intra',
'localtax1_assuj',
'localtax1_value',
'localtax2_assuj',
'localtax2_value',
'managers',
'capital',
'typent_code',
'forme_juridique_code',
'code_client',
'code_fournisseur'
399 if (!is_object($value)) $this->object_data->thirdparty->{$key} = $value;
406 $this->object_data->mycompany =
new stdClass();
408 foreach ($mysoc as $key=>$value)
410 if (in_array($key, $arrayoffieldstoexclude))
continue;
411 if (!in_array($key, array(
412 'name',
'name_alias',
'ref_ext',
'address',
'zip',
'town',
'state_code',
'country_code',
'idprof1',
'idprof2',
'idprof3',
'idprof4',
'idprof5',
'idprof6',
'phone',
'fax',
'email',
'barcode',
413 'tva_intra',
'localtax1_assuj',
'localtax1_value',
'localtax2_assuj',
'localtax2_value',
'managers',
'capital',
'typent_code',
'forme_juridique_code',
'code_client',
'code_fournisseur'
415 if (!is_object($value)) $this->object_data->mycompany->{$key} = $value;
422 $this->fk_user = $user->id;
423 $this->user_fullname = $user->getFullName($langs);
427 if ($this->element ==
'facture')
429 foreach ($object as $key=>$value)
431 if (in_array($key, $arrayoffieldstoexclude))
continue;
432 if (!in_array($key, array(
433 'ref',
'ref_client',
'ref_supplier',
'date',
'datef',
'datev',
'type',
'total_ht',
'total_tva',
'total_ttc',
'localtax1',
'localtax2',
'revenuestamp',
'datepointoftax',
'note_public',
'lines'
438 foreach ($value as $tmpline)
441 foreach ($tmpline as $keyline => $valueline)
443 if (!in_array($keyline, array(
444 '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'
447 if (empty($this->object_data->invoiceline[$lineid]) || !is_object($this->object_data->invoiceline[$lineid])) {
448 $this->object_data->invoiceline[$lineid] =
new stdClass();
451 $this->object_data->invoiceline[$lineid]->{$keyline} = $valueline;
454 } elseif (!is_object($value)) $this->object_data->{$key} = $value;
457 if (!empty($object->newref)) $this->object_data->ref = $object->newref;
458 } elseif ($this->element ==
'invoice_supplier')
460 foreach ($object as $key => $value)
462 if (in_array($key, $arrayoffieldstoexclude))
continue;
463 if (!in_array($key, array(
464 'ref',
'ref_client',
'ref_supplier',
'date',
'datef',
'type',
'total_ht',
'total_tva',
'total_ttc',
'localtax1',
'localtax2',
'revenuestamp',
'datepointoftax',
'note_public'
466 if (!is_object($value)) $this->object_data->{$key} = $value;
469 if (!empty($object->newref)) $this->object_data->ref = $object->newref;
470 } elseif ($this->element ==
'payment' || $this->element ==
'payment_supplier' || $this->element ==
'payment_donation' || $this->element ==
'payment_various')
472 $datepayment = $object->datepaye ? $object->datepaye : ($object->datepaid ? $object->datepaid : $object->datep);
473 $paymenttypeid = $object->paiementid ? $object->paiementid : ($object->paymenttype ? $object->paymenttype : $object->type_payment);
475 $this->object_data->ref = $object->ref;
476 $this->object_data->date = $datepayment;
477 $this->object_data->type_code =
dol_getIdFromCode($this->
db, $paymenttypeid,
'c_paiement',
'id',
'code');
478 $this->object_data->payment_num = $object->num_payment;
480 $this->object_data->note = $object->note;
485 if (!is_array($object->amounts) && $object->amount)
487 $object->amounts = array($object->id => $object->amount);
490 $paymentpartnumber = 0;
491 foreach ($object->amounts as $objid => $amount)
493 if (empty($amount))
continue;
495 $totalamount += $amount;
498 if ($this->element ==
'payment_supplier')
500 include_once DOL_DOCUMENT_ROOT.
'/fourn/class/fournisseur.facture.class.php';
502 } elseif ($this->element ==
'payment')
504 include_once DOL_DOCUMENT_ROOT.
'/compta/facture/class/facture.class.php';
506 } elseif ($this->element ==
'payment_donation')
508 include_once DOL_DOCUMENT_ROOT.
'/don/class/don.class.php';
509 $tmpobject =
new Don($this->
db);
510 } elseif ($this->element ==
'payment_various')
512 include_once DOL_DOCUMENT_ROOT.
'/compta/bank/class/paymentvarious.class.php';
516 if (!is_object($tmpobject))
521 $result = $tmpobject->fetch($objid);
525 $this->error = $tmpobject->error;
526 $this->errors = $tmpobject->errors;
527 dol_syslog(
"Failed to fetch object with id ".$objid, LOG_ERR);
531 $paymentpart =
new stdClass();
532 $paymentpart->amount = $amount;
534 if (!in_array($this->element, array(
'payment_donation',
'payment_various')))
536 $result = $tmpobject->fetch_thirdparty();
539 $this->error =
'Failed to fetch thirdparty for object with id '.$tmpobject->id;
540 $this->errors[] = $this->error;
541 dol_syslog(
"Failed to fetch thirdparty for object with id ".$tmpobject->id, LOG_ERR);
543 } elseif ($result < 0)
545 $this->error = $tmpobject->error;
546 $this->errors = $tmpobject->errors;
550 $paymentpart->thirdparty =
new stdClass();
551 foreach ($tmpobject->thirdparty as $key=>$value)
553 if (in_array($key, $arrayoffieldstoexclude))
continue;
554 if (!in_array($key, array(
555 'name',
'name_alias',
'ref_ext',
'address',
'zip',
'town',
'state_code',
'country_code',
'idprof1',
'idprof2',
'idprof3',
'idprof4',
'idprof5',
'idprof6',
'phone',
'fax',
'email',
'barcode',
556 'tva_intra',
'localtax1_assuj',
'localtax1_value',
'localtax2_assuj',
'localtax2_value',
'managers',
'capital',
'typent_code',
'forme_juridique_code',
'code_client',
'code_fournisseur'
558 if (!is_object($value)) $paymentpart->thirdparty->{$key} = $value;
563 if ($this->element ==
'payment_donation') $paymentpart->donation =
new stdClass();
564 else $paymentpart->invoice =
new stdClass();
566 if ($this->element !=
'payment_various')
568 foreach ($tmpobject as $key=>$value)
570 if (in_array($key, $arrayoffieldstoexclude))
continue;
571 if (!in_array($key, array(
572 'ref',
'ref_client',
'ref_supplier',
'date',
'datef',
'type',
'total_ht',
'total_tva',
'total_ttc',
'localtax1',
'localtax2',
'revenuestamp',
'datepointoftax',
'note_public'
574 if (!is_object($value))
576 if ($this->element ==
'payment_donation') $paymentpart->donation->{$key} = $value;
577 elseif ($this->element ==
'payment_various') $paymentpart->various->{$key} = $value;
578 else $paymentpart->invoice->{$key} = $value;
582 $paymentpartnumber++;
583 $this->object_data->payment_part[$paymentpartnumber] = $paymentpart;
587 $this->object_data->amount = $totalamount;
589 if (!empty($object->newref)) $this->object_data->ref = $object->newref;
590 } elseif ($this->element ==
'payment_salary')
592 $this->object_data->amounts = array($object->amount);
594 if (!empty($object->newref)) $this->object_data->ref = $object->newref;
595 } elseif ($this->element ==
'subscription')
597 foreach ($object as $key=>$value)
599 if (in_array($key, $arrayoffieldstoexclude))
continue;
600 if (!in_array($key, array(
601 'id',
'datec',
'dateh',
'datef',
'fk_adherent',
'amount',
'import_key',
'statut',
'note'
603 if (!is_object($value)) $this->object_data->{$key} = $value;
606 if (!empty($object->newref)) $this->object_data->ref = $object->newref;
609 foreach ($object as $key=>$value)
611 if (in_array($key, $arrayoffieldstoexclude))
continue;
612 if (!is_object($value)) $this->object_data->{$key} = $value;
615 if (!empty($object->newref)) $this->object_data->ref = $object->newref;
632 dol_syslog(get_class($this).
"::fetch id=".$id, LOG_DEBUG);
636 $this->error =
'BadParameter';
640 $langs->load(
"blockedlog");
642 $sql =
"SELECT b.rowid, b.date_creation, b.signature, b.signature_line, b.amounts, b.action, b.element, b.fk_object, b.entity,";
643 $sql .=
" b.certified, b.tms, b.fk_user, b.user_fullname, b.date_object, b.ref_object, b.object_data, b.object_version";
644 $sql .=
" FROM ".MAIN_DB_PREFIX.
"blockedlog as b";
645 if ($id) $sql .=
" WHERE b.rowid = ".$id;
652 $obj = $this->
db->fetch_object(
$resql);
654 $this->
id = $obj->rowid;
655 $this->entity = $obj->entity;
656 $this->ref = $obj->rowid;
658 $this->date_creation = $this->
db->jdate($obj->date_creation);
659 $this->tms = $this->
db->jdate($obj->tms);
661 $this->amounts = (double) $obj->amounts;
662 $this->action = $obj->action;
663 $this->element = $obj->element;
665 $this->fk_object = $obj->fk_object;
666 $this->date_object = $this->db->jdate($obj->date_object);
667 $this->ref_object = $obj->ref_object;
669 $this->fk_user = $obj->fk_user;
670 $this->user_fullname = $obj->user_fullname;
672 $this->object_data = $this->dolDecodeBlockedData($obj->object_data);
673 $this->object_version = $obj->object_version;
675 $this->signature = $obj->signature;
676 $this->signature_line = $obj->signature_line;
677 $this->certified = ($obj->certified == 1);
681 $this->error = $langs->trans(
"RecordNotFound");
685 $this->error = $this->
db->error();
703 $aaa = unserialize($data);
720 $res = $this->
db->query(
"UPDATE ".MAIN_DB_PREFIX.
"blockedlog SET certified=1 WHERE rowid=".$this->id);
721 if ($res ===
false)
return false;
733 public function create($user, $forcesignature =
'')
736 global $conf, $langs, $hookmanager;
738 $langs->load(
'blockedlog');
743 $this->amounts = (double) $this->amounts;
745 dol_syslog(get_class($this).
'::create action='.$this->action.
' fk_user='.$this->fk_user.
' user_fullname='.$this->user_fullname, LOG_DEBUG);
748 if (!isset($this->amounts))
750 $this->error = $langs->trans(
"BlockLogNeedAmountsValue");
755 if (empty($this->element)) {
756 $this->error = $langs->trans(
"BlockLogNeedElement");
761 if (empty($this->action)) {
762 $this->error = $langs->trans(
"BadParameterWhenCallingCreateOfBlockedLog");
766 if (empty($this->fk_user)) $this->user_fullname =
'(Anonymous)';
768 $this->date_creation =
dol_now();
772 $previoushash = $this->getPreviousHash(1, 0);
774 $keyforsignature = $this->buildKeyForSignature();
776 $this->signature_line =
dol_hash($keyforsignature,
'5');
777 $this->signature =
dol_hash($previoushash.$keyforsignature,
'5');
778 if ($forcesignature) $this->signature = $forcesignature;
781 $sql =
"INSERT INTO ".MAIN_DB_PREFIX.
"blockedlog (";
782 $sql .=
" date_creation,";
785 $sql .=
" signature,";
786 $sql .=
" signature_line,";
788 $sql .=
" fk_object,";
789 $sql .=
" date_object,";
790 $sql .=
" ref_object,";
791 $sql .=
" object_data,";
792 $sql .=
" object_version,";
793 $sql .=
" certified,";
795 $sql .=
" user_fullname,";
797 $sql .=
") VALUES (";
798 $sql .=
"'".$this->db->idate($this->date_creation).
"',";
799 $sql .=
"'".$this->db->escape($this->action).
"',";
800 $sql .= $this->amounts.
",";
801 $sql .=
"'".$this->db->escape($this->signature).
"',";
802 $sql .=
"'".$this->db->escape($this->signature_line).
"',";
803 $sql .=
"'".$this->db->escape($this->element).
"',";
804 $sql .= $this->fk_object.
",";
805 $sql .=
"'".$this->db->idate($this->date_object).
"',";
806 $sql .=
"'".$this->db->escape($this->ref_object).
"',";
807 $sql .=
"'".$this->db->escape(serialize($this->object_data)).
"',";
808 $sql .=
"'".$this->db->escape($this->object_version).
"',";
810 $sql .= $this->fk_user.
",";
811 $sql .=
"'".$this->db->escape($this->user_fullname).
"',";
812 $sql .= ($this->entity ? $this->entity : $conf->entity);
815 $res = $this->
db->query($sql);
818 $id = $this->
db->last_insert_id(MAIN_DB_PREFIX.
"blockedlog");
828 $this->
db->rollback();
832 $this->error = $this->
db->error();
833 $this->
db->rollback();
848 if (empty($previoushash))
850 $previoushash = $this->getPreviousHash(0, $this->
id);
853 $keyforsignature = $this->buildKeyForSignature();
855 $signature_line =
dol_hash($keyforsignature,
'5');
856 $signature =
dol_hash($previoushash.$keyforsignature,
'5');
859 $res = ($signature === $this->signature);
862 $this->error =
'Signature KO';
878 if (((
int) $this->object_version) > 12) {
879 return $this->date_creation.
'|'.$this->action.
'|'.$this->amounts.
'|'.$this->ref_object.
'|'.$this->date_object.
'|'.$this->user_fullname.
'|'.print_r($this->object_data,
true);
881 return $this->date_creation.
'|'.$this->action.
'|'.$this->amounts.
'|'.$this->ref_object.
'|'.$this->date_object.
'|'.$this->user_fullname.
'|'.print_r($this->object_data,
true);
897 $previoussignature =
'';
899 $sql =
"SELECT rowid, signature FROM ".MAIN_DB_PREFIX.
"blockedlog";
900 $sql .=
" WHERE entity=".$conf->entity;
901 if ($beforeid) $sql .=
" AND rowid < ".(int) $beforeid;
902 $sql .=
" ORDER BY rowid DESC LIMIT 1";
903 $sql .= ($withlock ?
" FOR UPDATE " :
"");
907 $obj = $this->
db->fetch_object(
$resql);
910 $previoussignature = $obj->signature;
917 if (empty($previoussignature))
920 $previoussignature = $this->getSignature();
923 return $previoussignature;
942 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 =
'')
944 global $conf, $cachedlogs;
947 if (empty($cachedlogs)) $cachedlogs = array();
949 if ($element ==
'all') {
950 $sql =
"SELECT rowid FROM ".MAIN_DB_PREFIX.
"blockedlog
951 WHERE entity=".$conf->entity;
952 } elseif ($element ==
'not_certified') {
953 $sql =
"SELECT rowid FROM ".MAIN_DB_PREFIX.
"blockedlog
954 WHERE entity=".$conf->entity.
" AND certified = 0";
955 } elseif ($element ==
'just_certified') {
956 $sql =
"SELECT rowid FROM ".MAIN_DB_PREFIX.
"blockedlog
957 WHERE entity=".$conf->entity.
" AND certified = 1";
959 $sql =
"SELECT rowid FROM ".MAIN_DB_PREFIX.
"blockedlog
960 WHERE entity=".$conf->entity.
" AND element='".$element.
"' AND fk_object=".(int) $fk_object;
963 if ($search_fk_user > 0) $sql .=
natural_search(
"fk_user", $search_fk_user, 2);
964 if ($search_start > 0) $sql .=
" AND date_creation >= '".$this->db->idate($search_start).
"'";
965 if ($search_end > 0) $sql .=
" AND date_creation <= '".$this->db->idate($search_end).
"'";
966 if ($search_ref !=
'') $sql .=
natural_search(
"ref_object", $search_ref);
967 if ($search_amount !=
'') $sql .=
natural_search(
"amounts", $search_amount, 1);
968 if ($search_code !=
'' && $search_code !=
'-1') $sql .=
natural_search(
"action", $search_code, 3);
970 $sql .= $this->
db->order($sortfield, $sortorder);
971 $sql .= $this->
db->plimit($limit + 1);
973 $res = $this->
db->query($sql);
978 while ($obj = $this->
db->fetch_object($res))
987 if (!isset($cachedlogs[$obj->rowid]))
990 $b->fetch($obj->rowid);
992 $cachedlogs[$obj->rowid] = $b;
995 $results[] = $cachedlogs[$obj->rowid];
1011 global $db, $conf, $mysoc;
1013 if (empty($conf->global->BLOCKEDLOG_ENTITY_FINGERPRINT)) {
1014 require_once DOL_DOCUMENT_ROOT.
'/core/lib/admin.lib.php';
1015 require_once DOL_DOCUMENT_ROOT.
'/core/lib/security.lib.php';
1016 require_once DOL_DOCUMENT_ROOT.
'/core/lib/security2.lib.php';
1020 dolibarr_set_const($db,
'BLOCKEDLOG_ENTITY_FINGERPRINT', $fingerprint,
'chaine', 0,
'Numeric Unique Fingerprint', $conf->entity);
1022 $conf->global->BLOCKEDLOG_ENTITY_FINGERPRINT = $fingerprint;
1025 return $conf->global->BLOCKEDLOG_ENTITY_FINGERPRINT;
1041 $sql =
"SELECT rowid FROM ".MAIN_DB_PREFIX.
"blockedlog";
1042 $sql .=
" WHERE entity = ".$conf->entity;
1043 if ($ignoresystem) $sql .=
" AND action not in ('MODULE_SET','MODULE_RESET')";
1044 $sql .= $this->
db->plimit(1);
1046 $res = $this->
db->query($sql);
1049 $obj = $this->
db->fetch_object($res);
1050 if ($obj) $result =
true;
1053 dol_syslog(
"Module Blockedlog alreadyUsed with ignoresystem=".$ignoresystem.
" is ".$result);
buildKeyForSignature()
Return a string for signature.
__construct(DoliDB $db)
Constructor.
dol_hash($chain, $type= '0')
Returns a hash of a string.
alreadyUsed($ignoresystem=0)
Check if module was already used or not for at least one recording.
Class to manage various payments.
getPreviousHash($withlock=0, $beforeid=0)
Get previous signature/hash in chain.
getSignature()
Return the signature (hash) of the "genesis-block" (Block 0).
setObjectData(&$object, $action, $amounts, $fuser=null)
Populate properties of log from object data.
getUser()
try to retrieve user author
dol_now($mode= 'auto')
Return date for now.
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 cash fence.
Class to manage Dolibarr users.
Class to manage Dolibarr database access.
create($user, $forcesignature= '')
Create blocked log in database.
fetch($id)
Get object from database.
checkSignature($previoushash= '')
Check if current signature still correct compared to the value in chain.
Class to manage suppliers invoices.
$conf db
API class for accounts.
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)
getObjectLink()
Try to retrieve source object (it it still exists)
Class to manage Blocked Log.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename= '', $restricttologhandler= '', $logcontext=null)
Write log message into outputs.
Class to manage payments of customer invoices.
getRandomPassword($generic=false, $replaceambiguouschars=null, $length=32)
Return a generated password using default module.
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...
dolDecodeBlockedData($data, $mode=0)
Decode data.
Class to manage subscriptions of foundation members.
Class to manage payments of donations.
dol_getIdFromCode($db, $key, $tablename, $fieldkey= 'code', $fieldid= 'id', $entityfilter=0)
Return an id or code from a code or id.
Class to manage donations.
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...
Class to manage invoices.
Class to manage payments for supplier invoices.
setCertified()
Set block certified by authority.