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();
144 $this->trackedevents[
'BILL_VALIDATE'] =
'logBILL_VALIDATE';
145 $this->trackedevents[
'BILL_DELETE'] =
'logBILL_DELETE';
146 $this->trackedevents[
'BILL_SENTBYMAIL'] =
'logBILL_SENTBYMAIL';
147 $this->trackedevents[
'DOC_DOWNLOAD'] =
'BlockedLogBillDownload';
148 $this->trackedevents[
'DOC_PREVIEW'] =
'BlockedLogBillPreview';
149 $this->trackedevents[
'PAYMENT_CUSTOMER_CREATE'] =
'logPAYMENT_CUSTOMER_CREATE';
150 $this->trackedevents[
'PAYMENT_CUSTOMER_DELETE'] =
'logPAYMENT_CUSTOMER_DELETE';
166 if (!empty($conf->don->enabled)) {
167 $this->trackedevents[
'DON_VALIDATE'] =
'logDON_VALIDATE';
168 $this->trackedevents[
'DON_DELETE'] =
'logDON_DELETE';
170 $this->trackedevents[
'DONATION_PAYMENT_CREATE'] =
'logDONATION_PAYMENT_CREATE';
171 $this->trackedevents[
'DONATION_PAYMENT_DELETE'] =
'logDONATION_PAYMENT_DELETE';
182 if (!empty($conf->adherent->enabled)) {
183 $this->trackedevents[
'MEMBER_SUBSCRIPTION_CREATE'] =
'logMEMBER_SUBSCRIPTION_CREATE';
184 $this->trackedevents[
'MEMBER_SUBSCRIPTION_MODIFY'] =
'logMEMBER_SUBSCRIPTION_MODIFY';
185 $this->trackedevents[
'MEMBER_SUBSCRIPTION_DELETE'] =
'logMEMBER_SUBSCRIPTION_DELETE';
187 if (!empty($conf->banque->enabled)) {
188 $this->trackedevents[
'PAYMENT_VARIOUS_CREATE'] =
'logPAYMENT_VARIOUS_CREATE';
189 $this->trackedevents[
'PAYMENT_VARIOUS_MODIFY'] =
'logPAYMENT_VARIOUS_MODIFY';
190 $this->trackedevents[
'PAYMENT_VARIOUS_DELETE'] =
'logPAYMENT_VARIOUS_DELETE';
193 $moduleposenabled = (!empty($conf->cashdesk->enabled) || !empty($conf->takepos->enabled) || !empty($conf->global->BANK_ENABLE_POS_CASHCONTROL));
194 if ($moduleposenabled) {
195 $this->trackedevents[
'CASHCONTROL_VALIDATE'] =
'logCASHCONTROL_VALIDATE';
199 if (!empty($conf->global->BLOCKEDLOG_ADD_ACTIONS_SUPPORTED)) {
200 $tmparrayofmoresupportedevents = explode(
',', $conf->global->BLOCKEDLOG_ADD_ACTIONS_SUPPORTED);
201 foreach ($tmparrayofmoresupportedevents as $val) {
202 $this->trackedevents[$val] =
'log'.$val;
218 if ($this->element ===
'facture') {
219 require_once DOL_DOCUMENT_ROOT.
'/compta/facture/class/facture.class.php';
222 if ($object->fetch($this->fk_object) > 0) {
223 return $object->getNomUrl(1);
228 if ($this->element ===
'invoice_supplier') {
229 require_once DOL_DOCUMENT_ROOT.
'/fourn/class/fournisseur.facture.class.php';
232 if ($object->fetch($this->fk_object) > 0) {
233 return $object->getNomUrl(1);
237 } elseif ($this->element ===
'payment') {
238 require_once DOL_DOCUMENT_ROOT.
'/compta/paiement/class/paiement.class.php';
241 if ($object->fetch($this->fk_object) > 0) {
242 return $object->getNomUrl(1);
246 } elseif ($this->element ===
'payment_supplier') {
247 require_once DOL_DOCUMENT_ROOT.
'/fourn/class/paiementfourn.class.php';
250 if ($object->fetch($this->fk_object) > 0) {
251 return $object->getNomUrl(1);
255 } elseif ($this->element ===
'payment_donation') {
256 require_once DOL_DOCUMENT_ROOT.
'/don/class/paymentdonation.class.php';
259 if ($object->fetch($this->fk_object) > 0) {
260 return $object->getNomUrl(1);
264 } elseif ($this->element ===
'payment_various') {
265 require_once DOL_DOCUMENT_ROOT.
'/compta/bank/class/paymentvarious.class.php';
268 if ($object->fetch($this->fk_object) > 0) {
269 return $object->getNomUrl(1);
273 } elseif ($this->element ===
'don' || $this->element ===
'donation') {
274 require_once DOL_DOCUMENT_ROOT.
'/don/class/don.class.php';
276 $object =
new Don($this->
db);
277 if ($object->fetch($this->fk_object) > 0) {
278 return $object->getNomUrl(1);
282 } elseif ($this->element ===
'subscription') {
283 require_once DOL_DOCUMENT_ROOT.
'/adherents/class/subscription.class.php';
286 if ($object->fetch($this->fk_object) > 0) {
287 return $object->getNomUrl(1);
291 } elseif ($this->element ===
'cashcontrol') {
292 require_once DOL_DOCUMENT_ROOT.
'/compta/cashcontrol/class/cashcontrol.class.php';
295 if ($object->fetch($this->fk_object) > 0) {
296 return $object->getNomUrl(1);
300 } elseif ($this->action ==
'MODULE_SET') {
301 return '<i class="opacitymedium">'.$langs->trans(
"BlockedLogEnabled").
'</i>';
302 } elseif ($this->action ==
'MODULE_RESET') {
303 if ($this->signature ==
'0000000000') {
304 return '<i class="opacitymedium">'.$langs->trans(
"BlockedLogDisabled").
'</i>';
306 return '<i class="opacitymedium">'.$langs->trans(
"BlockedLogDisabledBis").
'</i>';
310 return '<i class="opacitymedium">'.$langs->trans(
'ImpossibleToReloadObject', $this->element, $this->fk_object).
'</i>';
319 global $langs, $cachedUser;
321 if (empty($cachedUser)) {
322 $cachedUser = array();
325 if (empty($cachedUser[$this->fk_user])) {
327 if ($u->fetch($this->fk_user) > 0) {
328 $cachedUser[$this->fk_user] = $u;
332 if (!empty($cachedUser[$this->fk_user])) {
333 return $cachedUser[$this->fk_user]->getNomUrl(1);
336 return $langs->trans(
'ImpossibleToRetrieveUser', $this->fk_user);
350 global $langs, $user, $mysoc;
352 if (is_object($fuser)) {
359 $this->action = $action;
361 $this->amounts = $amounts;
363 if ($object->element ==
'payment' || $object->element ==
'payment_supplier') {
364 $this->date_object = $object->datepaye;
365 } elseif ($object->element ==
'payment_salary') {
366 $this->date_object = $object->datev;
367 } elseif ($object->element ==
'payment_donation' || $object->element ==
'payment_various') {
368 $this->date_object = $object->datepaid ? $object->datepaid : $object->datep;
369 } elseif ($object->element ==
'subscription') {
370 $this->date_object = $object->dateh;
371 } elseif ($object->element ==
'cashcontrol') {
372 $this->date_object = $object->date_creation;
374 $this->date_object = $object->date;
377 $this->ref_object = ((!empty($object->newref)) ? $object->newref : $object->ref);
379 $this->element = $object->element;
381 $this->fk_object = $object->id;
385 $this->object_data =
new stdClass();
387 $arrayoffieldstoexclude = array(
388 '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',
389 'table_element_line',
'ismultientitymanaged',
'isextrafieldmanaged',
392 'fk_delivery_address',
397 if ($this->element ==
'cashcontrol') {
398 $arrayoffieldstoexclude = array_merge($arrayoffieldstoexclude, array(
399 'name',
'lastname',
'firstname',
'region',
'region_id',
'region_code',
'state',
'state_id',
'state_code',
'country',
'country_id',
'country_code',
400 'total_ht',
'total_tva',
'total_ttc',
'total_localtax1',
'total_localtax2',
401 'barcode_type',
'barcode_type_code',
'barcode_type_label',
'barcode_type_coder',
'mode_reglement_id',
'cond_reglement_id',
'mode_reglement',
'cond_reglement',
'shipping_method_id',
402 'fk_incoterms',
'label_incoterms',
'location_incoterms',
'lines'));
406 if (empty($object->thirdparty) && method_exists($object,
'fetch_thirdparty')) {
407 $object->fetch_thirdparty();
409 if (!empty($object->thirdparty)) {
410 $this->object_data->thirdparty =
new stdClass();
412 foreach ($object->thirdparty as $key => $value) {
413 if (in_array($key, $arrayoffieldstoexclude)) {
416 if (!in_array($key, array(
417 'name',
'name_alias',
'ref_ext',
'address',
'zip',
'town',
'state_code',
'country_code',
'idprof1',
'idprof2',
'idprof3',
'idprof4',
'idprof5',
'idprof6',
'phone',
'fax',
'email',
'barcode',
418 'tva_intra',
'localtax1_assuj',
'localtax1_value',
'localtax2_assuj',
'localtax2_value',
'managers',
'capital',
'typent_code',
'forme_juridique_code',
'code_client',
'code_fournisseur'
422 if (!is_object($value) && !is_null($value) && $value !==
'') {
423 $this->object_data->thirdparty->{$key} = $value;
429 if (!empty($mysoc)) {
430 $this->object_data->mycompany =
new stdClass();
432 foreach ($mysoc as $key => $value) {
433 if (in_array($key, $arrayoffieldstoexclude)) {
436 if (!in_array($key, array(
437 'name',
'name_alias',
'ref_ext',
'address',
'zip',
'town',
'state_code',
'country_code',
'idprof1',
'idprof2',
'idprof3',
'idprof4',
'idprof5',
'idprof6',
'phone',
'fax',
'email',
'barcode',
438 'tva_intra',
'localtax1_assuj',
'localtax1_value',
'localtax2_assuj',
'localtax2_value',
'managers',
'capital',
'typent_code',
'forme_juridique_code',
'code_client',
'code_fournisseur'
442 if (!is_object($value) && !is_null($value) && $value !==
'') {
443 $this->object_data->mycompany->{$key} = $value;
450 $this->fk_user = $user->id;
451 $this->user_fullname = $user->getFullName($langs);
455 if ($this->element ==
'facture') {
456 foreach ($object as $key => $value) {
457 if (in_array($key, $arrayoffieldstoexclude)) {
460 if (!in_array($key, array(
461 'ref',
'ref_client',
'ref_supplier',
'date',
'datef',
'datev',
'type',
'total_ht',
'total_tva',
'total_ttc',
'localtax1',
'localtax2',
'revenuestamp',
'datepointoftax',
'note_public',
'lines'
465 if ($key ==
'lines') {
467 foreach ($value as $tmpline) {
469 foreach ($tmpline as $keyline => $valueline) {
470 if (!in_array($keyline, array(
471 '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'
476 if (empty($this->object_data->invoiceline[$lineid]) || !is_object($this->object_data->invoiceline[$lineid])) {
477 $this->object_data->invoiceline[$lineid] =
new stdClass();
480 if (!is_object($valueline) && !is_null($valueline) && $valueline !==
'') {
481 $this->object_data->invoiceline[$lineid]->{$keyline} = $valueline;
485 } elseif (!is_object($value) && !is_null($value) && $value !==
'') {
486 $this->object_data->{$key} = $value;
490 if (!empty($object->newref)) {
491 $this->object_data->ref = $object->newref;
493 } elseif ($this->element ==
'invoice_supplier') {
494 foreach ($object as $key => $value) {
495 if (in_array($key, $arrayoffieldstoexclude)) {
498 if (!in_array($key, array(
499 'ref',
'ref_client',
'ref_supplier',
'date',
'datef',
'type',
'total_ht',
'total_tva',
'total_ttc',
'localtax1',
'localtax2',
'revenuestamp',
'datepointoftax',
'note_public'
503 if (!is_object($value) && !is_null($value) && $value !==
'') {
504 $this->object_data->{$key} = $value;
508 if (!empty($object->newref)) {
509 $this->object_data->ref = $object->newref;
511 } elseif ($this->element ==
'payment' || $this->element ==
'payment_supplier' || $this->element ==
'payment_donation' || $this->element ==
'payment_various') {
512 $datepayment = $object->datepaye ? $object->datepaye : ($object->datepaid ? $object->datepaid : $object->datep);
513 $paymenttypeid = $object->paiementid ? $object->paiementid : ($object->paymenttype ? $object->paymenttype : $object->type_payment);
515 $this->object_data->ref = $object->ref;
516 $this->object_data->date = $datepayment;
517 $this->object_data->type_code =
dol_getIdFromCode($this->
db, $paymenttypeid,
'c_paiement',
'id',
'code');
519 if (!empty($object->num_payment)) {
520 $this->object_data->payment_num = $object->num_payment;
522 if (!empty($object->note_private)) {
523 $this->object_data->note_private = $object->note_private;
531 if (is_array($object->amounts) && !empty($object->amounts)) {
532 $paymentpartnumber = 0;
533 foreach ($object->amounts as $objid => $amount) {
534 if (empty($amount)) {
538 $totalamount += $amount;
541 if ($this->element ==
'payment_supplier') {
542 include_once DOL_DOCUMENT_ROOT.
'/fourn/class/fournisseur.facture.class.php';
544 } elseif ($this->element ==
'payment') {
545 include_once DOL_DOCUMENT_ROOT.
'/compta/facture/class/facture.class.php';
547 } elseif ($this->element ==
'payment_donation') {
548 include_once DOL_DOCUMENT_ROOT.
'/don/class/don.class.php';
549 $tmpobject =
new Don($this->
db);
550 } elseif ($this->element ==
'payment_various') {
551 include_once DOL_DOCUMENT_ROOT.
'/compta/bank/class/paymentvarious.class.php';
555 if (!is_object($tmpobject)) {
559 $result = $tmpobject->fetch($objid);
562 $this->error = $tmpobject->error;
563 $this->errors = $tmpobject->errors;
564 dol_syslog(
"Failed to fetch object with id ".$objid, LOG_ERR);
568 $paymentpart =
new stdClass();
569 $paymentpart->amount = $amount;
571 if (!in_array($this->element, array(
'payment_donation',
'payment_various'))) {
572 $result = $tmpobject->fetch_thirdparty();
574 $this->error =
'Failed to fetch thirdparty for object with id '.$tmpobject->id;
575 $this->errors[] = $this->error;
576 dol_syslog(
"Failed to fetch thirdparty for object with id ".$tmpobject->id, LOG_ERR);
578 } elseif ($result < 0) {
579 $this->error = $tmpobject->error;
580 $this->errors = $tmpobject->errors;
584 $paymentpart->thirdparty =
new stdClass();
585 foreach ($tmpobject->thirdparty as $key => $value) {
586 if (in_array($key, $arrayoffieldstoexclude)) {
589 if (!in_array($key, array(
590 'name',
'name_alias',
'ref_ext',
'address',
'zip',
'town',
'state_code',
'country_code',
'idprof1',
'idprof2',
'idprof3',
'idprof4',
'idprof5',
'idprof6',
'phone',
'fax',
'email',
'barcode',
591 'tva_intra',
'localtax1_assuj',
'localtax1_value',
'localtax2_assuj',
'localtax2_value',
'managers',
'capital',
'typent_code',
'forme_juridique_code',
'code_client',
'code_fournisseur'
595 if (!is_object($value) && !is_null($value) && $value !==
'') {
596 $paymentpart->thirdparty->{$key} = $value;
602 if ($this->element ==
'payment_donation') {
603 $paymentpart->donation =
new stdClass();
605 $paymentpart->invoice =
new stdClass();
608 if ($this->element !=
'payment_various') {
609 foreach ($tmpobject as $key => $value) {
610 if (in_array($key, $arrayoffieldstoexclude)) {
613 if (!in_array($key, array(
614 'ref',
'ref_client',
'ref_supplier',
'date',
'datef',
'type',
'total_ht',
'total_tva',
'total_ttc',
'localtax1',
'localtax2',
'revenuestamp',
'datepointoftax',
'note_public'
618 if (!is_object($value) && !is_null($value) && $value !==
'') {
619 if ($this->element ==
'payment_donation') {
620 $paymentpart->donation->{$key} = $value;
621 } elseif ($this->element ==
'payment_various') {
622 $paymentpart->various->{$key} = $value;
624 $paymentpart->invoice->{$key} = $value;
629 $paymentpartnumber++;
630 $this->object_data->payment_part[$paymentpartnumber] = $paymentpart;
633 } elseif (!empty($object->amount)) {
634 $totalamount = $object->amount;
637 $this->object_data->amount = $totalamount;
639 if (!empty($object->newref)) {
640 $this->object_data->ref = $object->newref;
642 } elseif ($this->element ==
'payment_salary') {
643 $this->object_data->amounts = array($object->amount);
645 if (!empty($object->newref)) {
646 $this->object_data->ref = $object->newref;
648 } elseif ($this->element ==
'subscription') {
649 foreach ($object as $key => $value) {
650 if (in_array($key, $arrayoffieldstoexclude)) {
653 if (!in_array($key, array(
654 'id',
'datec',
'dateh',
'datef',
'fk_adherent',
'amount',
'import_key',
'statut',
'note'
658 if (!is_object($value) && !is_null($value) && $value !==
'') {
659 $this->object_data->{$key} = $value;
663 if (!empty($object->newref)) {
664 $this->object_data->ref = $object->newref;
668 foreach ($object as $key => $value) {
669 if (in_array($key, $arrayoffieldstoexclude)) {
672 if (!is_object($value) && !is_null($value) && $value !==
'') {
673 $this->object_data->{$key} = $value;
677 if (!empty($object->newref)) {
678 $this->object_data->ref = $object->newref;
696 $this->error =
'BadParameter';
700 $sql =
"SELECT b.rowid, b.date_creation, b.signature, b.signature_line, b.amounts, b.action, b.element, b.fk_object, b.entity,";
701 $sql .=
" b.certified, b.tms, b.fk_user, b.user_fullname, b.date_object, b.ref_object, b.object_data, b.object_version";
702 $sql .=
" FROM ".MAIN_DB_PREFIX.
"blockedlog as b";
704 $sql .=
" WHERE b.rowid = ".((int) $id);
709 $obj = $this->
db->fetch_object(
$resql);
711 $this->
id = $obj->rowid;
712 $this->entity = $obj->entity;
713 $this->
ref = $obj->rowid;
715 $this->date_creation = $this->
db->jdate($obj->date_creation);
716 $this->tms = $this->
db->jdate($obj->tms);
718 $this->amounts = (double) $obj->amounts;
719 $this->action = $obj->action;
720 $this->element = $obj->element;
722 $this->fk_object = $obj->fk_object;
723 $this->date_object = $this->db->jdate($obj->date_object);
724 $this->ref_object = $obj->ref_object;
726 $this->fk_user = $obj->fk_user;
727 $this->user_fullname = $obj->user_fullname;
729 $this->object_data = $this->dolDecodeBlockedData($obj->object_data);
730 $this->object_version = $obj->object_version;
732 $this->signature = $obj->signature;
733 $this->signature_line = $obj->signature_line;
734 $this->certified = ($obj->certified == 1);
738 $langs->load(
"blockedlog");
739 $this->error = $langs->trans(
"RecordNotFound");
743 $this->error = $this->
db->error();
760 $aaa = unserialize($data);
776 $res = $this->
db->query(
"UPDATE ".MAIN_DB_PREFIX.
"blockedlog SET certified=1 WHERE rowid=".((
int) $this->id));
791 public function create($user, $forcesignature =
'')
793 global $conf, $langs, $hookmanager;
795 $langs->load(
'blockedlog');
800 $this->amounts = (double) $this->amounts;
802 dol_syslog(get_class($this).
'::create action='.$this->action.
' fk_user='.$this->fk_user.
' user_fullname='.$this->user_fullname, LOG_DEBUG);
805 if (!isset($this->amounts)) {
806 $this->error = $langs->trans(
"BlockLogNeedAmountsValue");
811 if (empty($this->element)) {
812 $this->error = $langs->trans(
"BlockLogNeedElement");
817 if (empty($this->action)) {
818 $this->error = $langs->trans(
"BadParameterWhenCallingCreateOfBlockedLog");
822 if (empty($this->fk_user)) {
823 $this->user_fullname =
'(Anonymous)';
826 $this->date_creation =
dol_now();
830 $previoushash = $this->getPreviousHash(1, 0);
832 $keyforsignature = $this->buildKeyForSignature();
834 include_once DOL_DOCUMENT_ROOT.
'/core/lib/security.lib.php';
836 $this->signature_line =
dol_hash($keyforsignature,
'5');
837 $this->signature =
dol_hash($previoushash.$keyforsignature,
'5');
838 if ($forcesignature) {
839 $this->signature = $forcesignature;
843 $sql =
"INSERT INTO ".MAIN_DB_PREFIX.
"blockedlog (";
844 $sql .=
" date_creation,";
847 $sql .=
" signature,";
848 $sql .=
" signature_line,";
850 $sql .=
" fk_object,";
851 $sql .=
" date_object,";
852 $sql .=
" ref_object,";
853 $sql .=
" object_data,";
854 $sql .=
" object_version,";
855 $sql .=
" certified,";
857 $sql .=
" user_fullname,";
859 $sql .=
") VALUES (";
860 $sql .=
"'".$this->db->idate($this->date_creation).
"',";
861 $sql .=
"'".$this->db->escape($this->action).
"',";
862 $sql .= $this->amounts.
",";
863 $sql .=
"'".$this->db->escape($this->signature).
"',";
864 $sql .=
"'".$this->db->escape($this->signature_line).
"',";
865 $sql .=
"'".$this->db->escape($this->element).
"',";
866 $sql .= $this->fk_object.
",";
867 $sql .=
"'".$this->db->idate($this->date_object).
"',";
868 $sql .=
"'".$this->db->escape($this->ref_object).
"',";
869 $sql .=
"'".$this->db->escape(serialize($this->object_data)).
"',";
870 $sql .=
"'".$this->db->escape($this->object_version).
"',";
872 $sql .= $this->fk_user.
",";
873 $sql .=
"'".$this->db->escape($this->user_fullname).
"',";
874 $sql .= ($this->entity ? $this->entity : $conf->entity);
877 $res = $this->
db->query($sql);
879 $id = $this->
db->last_insert_id(MAIN_DB_PREFIX.
"blockedlog");
888 $this->
db->rollback();
892 $this->error = $this->
db->error();
893 $this->
db->rollback();
909 if (empty($previoushash)) {
910 $previoushash = $this->getPreviousHash(0, $this->
id);
913 $keyforsignature = $this->buildKeyForSignature();
916 $signature =
dol_hash($previoushash.$keyforsignature,
'5');
919 $res = ($signature === $this->signature);
922 $this->error =
'Signature KO';
926 if ($returnarray == 1) {
927 unset($keyforsignature);
928 return array(
'checkresult' => $res,
'calculatedsignature' => $signature,
'previoushash' => $previoushash);
930 return array(
'checkresult' => $res,
'calculatedsignature' => $signature,
'previoushash' => $previoushash,
'keyforsignature'=>$keyforsignature);
933 unset($keyforsignature);
948 if (((
int) $this->object_version) > 12) {
949 return $this->date_creation.
'|'.$this->action.
'|'.$this->amounts.
'|'.$this->ref_object.
'|'.$this->date_object.
'|'.$this->user_fullname.
'|'.print_r($this->object_data,
true);
951 return $this->date_creation.
'|'.$this->action.
'|'.$this->amounts.
'|'.$this->ref_object.
'|'.$this->date_object.
'|'.$this->user_fullname.
'|'.print_r($this->object_data,
true);
967 $previoussignature =
'';
969 $sql =
"SELECT rowid, signature FROM ".MAIN_DB_PREFIX.
"blockedlog";
970 $sql .=
" WHERE entity=".$conf->entity;
972 $sql .=
" AND rowid < ".(int) $beforeid;
974 $sql .=
" ORDER BY rowid DESC LIMIT 1";
975 $sql .= ($withlock ?
" FOR UPDATE " :
"");
979 $obj = $this->
db->fetch_object(
$resql);
981 $previoussignature = $obj->signature;
988 if (empty($previoussignature)) {
990 $previoussignature = $this->getSignature();
993 return $previoussignature;
1012 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 =
'')
1020 if ($element ==
'all') {
1021 $sql =
"SELECT rowid FROM ".MAIN_DB_PREFIX.
"blockedlog
1022 WHERE entity=".$conf->entity;
1023 } elseif ($element ==
'not_certified') {
1024 $sql =
"SELECT rowid FROM ".MAIN_DB_PREFIX.
"blockedlog
1025 WHERE entity=".$conf->entity.
" AND certified = 0";
1026 } elseif ($element ==
'just_certified') {
1027 $sql =
"SELECT rowid FROM ".MAIN_DB_PREFIX.
"blockedlog
1028 WHERE entity=".$conf->entity.
" AND certified = 1";
1030 $sql =
"SELECT rowid FROM ".MAIN_DB_PREFIX.
"blockedlog
1031 WHERE entity=".$conf->entity.
" AND element='".$this->
db->escape($element).
"'";
1037 if ($search_fk_user > 0) {
1040 if ($search_start > 0) {
1041 $sql .=
" AND date_creation >= '".$this->db->idate($search_start).
"'";
1043 if ($search_end > 0) {
1044 $sql .=
" AND date_creation <= '".$this->db->idate($search_end).
"'";
1046 if ($search_ref !=
'') {
1049 if ($search_amount !=
'') {
1052 if ($search_code !=
'' && $search_code !=
'-1') {
1056 $sql .= $this->
db->order($sortfield, $sortorder);
1057 $sql .= $this->
db->plimit($limit + 1);
1059 $res = $this->
db->query($sql);
1064 while ($obj = $this->
db->fetch_object($res)) {
1074 $b->fetch($obj->rowid);
1096 global $db, $conf, $mysoc;
1098 if (empty($conf->global->BLOCKEDLOG_ENTITY_FINGERPRINT)) {
1099 require_once DOL_DOCUMENT_ROOT.
'/core/lib/admin.lib.php';
1100 require_once DOL_DOCUMENT_ROOT.
'/core/lib/security.lib.php';
1101 require_once DOL_DOCUMENT_ROOT.
'/core/lib/security2.lib.php';
1105 dolibarr_set_const($db,
'BLOCKEDLOG_ENTITY_FINGERPRINT', $fingerprint,
'chaine', 0,
'Numeric Unique Fingerprint', $conf->entity);
1107 $conf->global->BLOCKEDLOG_ENTITY_FINGERPRINT = $fingerprint;
1110 return $conf->global->BLOCKEDLOG_ENTITY_FINGERPRINT;
1126 $sql =
"SELECT rowid FROM ".MAIN_DB_PREFIX.
"blockedlog";
1127 $sql .=
" WHERE entity = ".$conf->entity;
1128 if ($ignoresystem) {
1129 $sql .=
" AND action not in ('MODULE_SET','MODULE_RESET')";
1131 $sql .= $this->
db->plimit(1);
1133 $res = $this->
db->query($sql);
1134 if ($res !==
false) {
1135 $obj = $this->
db->fetch_object($res);
1143 dol_syslog(
"Module Blockedlog alreadyUsed with ignoresystem=".$ignoresystem.
" is ".$result);